2. CAPTURAS DE LA INSTALACIÓN DEL EMU8086
1. Abrir el instalador
2. Dar clic en siguiente
3. 3. Elegir la ruta de instalación y hacer clic en siguiente
4. Clic en siguiente y luego clic en instalar
4. 5. La instalación comenzará
6. Marcan las casillas correspondientes y dar clic en finish
5. EJECUCIÓN DEL HOLA MUNDO
Ejecutar el programa hola mundo, y debe cambiar los mensajes de pantalla al español.
Código
; The easiest way to print out "Hello, World!"
name "hi"
org 100h
jmp start ; jump over data declaration
msg: db "Hola mundo!", 0Dh,0Ah, 24h
start: mov dx, msg ; load offset of msg into dx.
mov ah, 09h ; print function is 9.
int 21h ; do it!
mov ah, 0
int 16h ; wait for any key....
ret ; return to operating system.
6. Compilar un programa en EMU8086 que indique lo siguiente:
Nombre completo del estudiante, Universidad, Fecha y materia.
CÓDIGO
; The easiest way to print out "Hello, World!"
name "hi"
org 100h
jmp start ; jump over data declaration
msg: db "ANTHONY SEBASTIAN BENALCAZAR CABRERA PUCESI (19 DE ABRIL DE 2018)
COMPILADORES", 0Dh,0Ah, 24h
start: mov dx, msg ; load offset of msg into dx.
mov ah, 09h ; print function is 9.
int 21h ; do it!
mov ah, 0
int 16h ; wait for any key....
ret ; return to operating system.
7. Compilar un programa que permita comparar 2 números del 0 al 9
Compara dos números diciendo si el primero que se ingresó es mayor o menor que el
segundo que se ingresó.
Código
.model small
.stack 64
.data
mayor1 Db 'Es mayor','$'
menor1 Db 'Es menor','$'
igual1 Db 'Son iguales','$'
.code
inicio:
mov ah,01
int 21h
mov bl,al
mov ah,01
int 21h
mov cl,al
cmp bl,cl
ja mayor
8. jb menor
je igual
mayor:
mov ax,@data
mov ds,ax
mov ah,09
mov dx,offset mayor1
int 21h
jmp salir
menor:
mov ax,@data
mov ds,ax
mov ah,09
mov dx,offset menor1
int 21h
jmp salir
igual:
mov ax,@data
mov ds,ax
mov ah,09
mov dx,offset igual1
int 21h
jmp salir
salir:
mov ah,4ch
int 21h
end inicio
9. Compilar un programa que permita sumar 10 valores asignados a un vector
Código
name "calc-sum"
org 100h ; directive make tiny com file.
; calculate the sum of elements in vector,
; store result in m and print it in binary code.
; number of elements:
mov cx, 10
; al will store the sum:
mov al, 0
; bx is an index:
10. mov bx, 0
; sum elements:
next: add al, vector[bx]
; next byte:
inc bx
; loop until cx=0:
loop next
; store result in m:
mov m, al
; print result in binary:
mov bl, m
mov cx, 8
print: mov ah, 2 ; print function.
mov dl, '0'
test bl, 10000000b ; test first bit.
jz zero
mov dl, '1'
zero: int 21h
shl bl, 1
loop print
; print binary suffix:
mov dl, 'b'
int 21h
mov dl, 0ah ; new line.
int 21h
mov dl, 0dh ; carrige return.
int 21h
; print result in decimal:
mov al, m
call print_al
11. ; wait for any key press:
mov ah, 0
int 16h
ret
; variables:
vector db 1,2,3,4,5,6,7,8,9,10
m db 0
print_al proc
cmp al, 0
jne print_al_r
push ax
mov al, '0'
mov ah, 0eh
int 10h
pop ax
ret
print_al_r:
pusha
mov ah, 0
cmp ax, 0
je pn_done
mov dl, 10
div dl
call print_al_r
mov al, ah
add al, 30h
mov ah, 0eh
int 10h
jmp pn_done
pn_done:
popa
ret
endp
12. Compilar un programa sugerido por usted, como propuesta adicional.
Programa que tome tres cadenas, la primera y la tercera representan un número y la
segunda una operación, por ejemplo: “300”, “-“, “100” e imprima el resultado “200”
Código
org 100h ; inicio de programa
include 'emu8086.inc' ;Incluye funciones de libreria emu8086
; DEFINE_SCAN_NUM
; DEFINE_PRINT_STRING
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS
mov si, 0
mov al, 0
;Convertir primera cadena a numero
cadAnum:
cmp cad1[si], "$"
jz seguir
mov bl, 10
13. mul bl
sub cad1[si], '0'
add al, cad1[si]
inc si
loop cadAnum
seguir:
mov aux1, al
;Convertir segunda cadena a numero
mov si, 0
mov al, 0
cadAnum2:
cmp cad3[si], "$"
jz seguir2
mov bl, 10
mul bl
sub cad3[si], '0'
add al, cad3[si]
inc si
loop cadAnum2
seguir2:
mov bl, al
mov al, aux1
;realizar operaciones normalmente teniendo ya los dos numeros decimales
cmp cad2, "-"
jz resta
cmp cad2, "+"
jz suma
cmp cad2, "*"
jz multi
cmp cad2, "/"
jz divi
resta:
sub al, bl
jmp fin
suma:
add al, bl
jmp fin
multi:
mul bl
14. jmp fin
divi:
div bl
jmp fin
fin:
mov bx, ax
mov ah,09
lea dx,msg
int 21h
mov ax, bx
call PRINT_NUM
ret
cad1 db "300$"
cad2 db "-"
cad3 db "100$"
aux1 db ?
aux2 dw ?
msg dw "El resultado es: $"