PONTIFICIA UNIVERSIDAD CATÓLICA DEL ECUADOR
SEDE IBARRA
Nombre: Liliana Chisaguano
Nivel: 5to Semestre
Materia: Compiladores
Fecha: 26/04/2017
INSTALACIÓN DE EMU8086
El Emulador EMU8086 es el primer programa que se utiliza en el curso de
Microprocesadores que imparte la Universidad Don Bosco; se ha elegido este emulador
porque posee una interfaz de usuario muy amistosa que permite familiarizarse con los
fundamentos de la programación en lenguaje ensamblador de forma muy intuitiva, aparte
de eso brinda una serie de recursos para ejecutar y depurar los programas.
También tiene algunas desventajas como el de no soportar algunas de las interrupciones
más interesantes que posee el sistema operativo y tampoco puede acceder a los puertos
físicos (reales), sino que los emula usando otros programas que ya están incluidos en su
respectiva carpeta.
 Link de la página para la descargar
http://assembler8086.blogspot.com/2012/10/ejercicios-en-emu-8086.html
EJERCICIOS:
• Ejecutar el programa hola mundo, y debe cambiar los mensajes de pantalla al español.
Código:
name "hola-mundo"
; this example prints out "hola mundo!"
; by writing directly to video memory.
; in vga memory: first byte is ascii character, byte that follows is character attribute.
; if you change the second byte, you can change the color of
; the character even after it is printed.
; character attribute is 8 bit value,
; high 4 bits set background color and low 4 bits set foreground color.
; hex bin color
;
; 0 0000 black
; 1 0001 blue
; 2 0010 green
; 3 0011 cyan
; 4 0100 red
; 5 0101 magenta
; 6 0110 brown
; 7 0111 light gray
; 8 1000 dark gray
; 9 1001 light blue
; a 1010 light green
; b 1011 light cyan
; c 1100 light red
; d 1101 light magenta
; e 1110 yellow
; f 1111 white
org 100h
; set video mode
mov ax, 3 ; text mode 80x25, 16 colors, 8 pages (ah=0, al=3)
int 10h ; do it!
; cancel blinking and enable all 16 colors:
mov ax, 1003h
mov bx, 0
int 10h
; set segment register:
mov ax, 0b800h
mov ds, ax
; print "hello world"
; first byte is ascii code, second byte is color code.
mov [02h], 'H'
mov [04h], 'o'
mov [06h], 'l'
mov [08h], 'a'
mov [0ch], ','
mov [0eh], 'm'
mov [10h], 'u'
mov [12h], 'n'
mov [14h], 'd'
mov [16h], 'o'
mov [18h], '!'
; color all characters:
mov cx, 12 ; number of characters.
mov di, 03h ; start from byte after 'h'
c: mov [di], 11101100b ; light red(1100) on yellow(1110)
add di, 2 ; skip over next ascii code in vga memory.
loop c
; wait for any key press:
mov ah, 0
int 16h
ret
 Nombre completo del estudiante, Universidad, Fecha y materia.
CODIGO:
CODE SEGMENT
ASSUME CS:CODE, DS:CODE, SS:CODE, ES:CODE
ORG 100h
codigo:
mov ah, 0Fh
mov ah, 0
int 10h
lea dx, mensaje
mov ah, 9h
int 21h
int 20h
mensaje db "Liliana Alexandra Chisaguano Chusete, Estudio en la PUCE-SI,26/04/2017
COMPILADORES $",0
CODE ENDS
ENDS end codigo
 Compilar un programa que permita comparar 2 números del 0 al 9.
Código:
name "flags"
org 100h
; this sample shows how cmp instruction sets the flags.
; usually cmp instruction is followed by any relative
; jump instruction such as: je, ja, jl, jae...
; it is recommended to click "flags" and "analyze"
; for better visual expirience before stepping through this code.
; (signed/unsigned)
; 4 is equal to 4
mov ah, 4
mov al, 4
cmp ah, al
nop
; (signed/unsigned)
; 4 is above and greater then 3
mov ah, 4
mov al, 3
cmp ah, al
nop
; -5 = 251 = 0fbh
; (signed)
; 1 is greater then -5
mov ah, 1
mov al, -5
cmp ah, al
nop
; (unsigned)
; 1 is below 251
mov ah, 1
mov al, 251
cmp ah, al
nop
; (signed)
; -3 is less then -2
mov ah, -3
mov al, -2
cmp ah, al
nop
; (signed)
; -2 is greater then -3
mov ah, -2
mov al, -3
cmp ah, al
nop
; (unsigned)
; 255 is above 1
mov ah, 255
mov al, 1
cmp ah, al
nop
; now a little game:
game: mov dx, offset msg1
mov ah, 9
int 21h
; read character in al:
mov ah, 1
int 21h
cmp al, '0'
jb stop
cmp al, '9'
ja stop
cmp al, '5'
jb below
ja above
mov dx, offset equal_5
jmp print
below: mov dx, offset below_5
jmp print
above: mov dx, offset above_5
print: mov ah, 9
int 21h
jmp game ; loop.
stop: ret ; stop
msg1 db "enter a number or any other character to exit: $"
equal_5 db " is five! (equal)", 0Dh,0Ah, "$"
below_5 db " is below five!" , 0Dh,0Ah, "$"
above_5 db " is above five!" , 0Dh,0Ah, "$"
• Compilar un programa que permita sumar 10 valores asignados a un vector.
Codigo:
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:
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
; wait for any key press:
mov ah, 0
int 16h
ret
; variables:
vector db 5, 5, 5, 5, 5, 1, 1, 1, 1, 1
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
• Compilar un programa sugerido por usted, como propuesta adicional.
CODIGO:
name "hex-bin"
org 100h
; load binary value:
; (hex: 5h)
mov al, 00000101b
; load hex value:
mov bl, 0ah
; load octal value:
; (hex: 8h)
mov cl, 10o
; 5 + 10 = 15 (0fh)
add al, bl
; 15 - 8 = 7
sub al, cl
; print result in binary:
mov bl, al
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
; wait for any key press:
mov ah, 0
int 16h
ret

INSTALACIÓN DE EMU8086

  • 1.
    PONTIFICIA UNIVERSIDAD CATÓLICADEL ECUADOR SEDE IBARRA Nombre: Liliana Chisaguano Nivel: 5to Semestre Materia: Compiladores Fecha: 26/04/2017 INSTALACIÓN DE EMU8086 El Emulador EMU8086 es el primer programa que se utiliza en el curso de Microprocesadores que imparte la Universidad Don Bosco; se ha elegido este emulador porque posee una interfaz de usuario muy amistosa que permite familiarizarse con los fundamentos de la programación en lenguaje ensamblador de forma muy intuitiva, aparte de eso brinda una serie de recursos para ejecutar y depurar los programas. También tiene algunas desventajas como el de no soportar algunas de las interrupciones más interesantes que posee el sistema operativo y tampoco puede acceder a los puertos físicos (reales), sino que los emula usando otros programas que ya están incluidos en su respectiva carpeta.  Link de la página para la descargar http://assembler8086.blogspot.com/2012/10/ejercicios-en-emu-8086.html
  • 4.
    EJERCICIOS: • Ejecutar elprograma hola mundo, y debe cambiar los mensajes de pantalla al español. Código: name "hola-mundo" ; this example prints out "hola mundo!" ; by writing directly to video memory. ; in vga memory: first byte is ascii character, byte that follows is character attribute. ; if you change the second byte, you can change the color of ; the character even after it is printed. ; character attribute is 8 bit value, ; high 4 bits set background color and low 4 bits set foreground color.
  • 5.
    ; hex bincolor ; ; 0 0000 black ; 1 0001 blue ; 2 0010 green ; 3 0011 cyan ; 4 0100 red ; 5 0101 magenta ; 6 0110 brown ; 7 0111 light gray ; 8 1000 dark gray ; 9 1001 light blue ; a 1010 light green ; b 1011 light cyan ; c 1100 light red ; d 1101 light magenta ; e 1110 yellow ; f 1111 white org 100h ; set video mode mov ax, 3 ; text mode 80x25, 16 colors, 8 pages (ah=0, al=3) int 10h ; do it! ; cancel blinking and enable all 16 colors: mov ax, 1003h mov bx, 0 int 10h ; set segment register: mov ax, 0b800h mov ds, ax ; print "hello world" ; first byte is ascii code, second byte is color code. mov [02h], 'H' mov [04h], 'o' mov [06h], 'l' mov [08h], 'a' mov [0ch], ',' mov [0eh], 'm' mov [10h], 'u' mov [12h], 'n' mov [14h], 'd' mov [16h], 'o' mov [18h], '!' ; color all characters: mov cx, 12 ; number of characters. mov di, 03h ; start from byte after 'h' c: mov [di], 11101100b ; light red(1100) on yellow(1110) add di, 2 ; skip over next ascii code in vga memory. loop c
  • 6.
    ; wait forany key press: mov ah, 0 int 16h ret  Nombre completo del estudiante, Universidad, Fecha y materia. CODIGO: CODE SEGMENT ASSUME CS:CODE, DS:CODE, SS:CODE, ES:CODE ORG 100h codigo: mov ah, 0Fh mov ah, 0 int 10h lea dx, mensaje mov ah, 9h int 21h int 20h mensaje db "Liliana Alexandra Chisaguano Chusete, Estudio en la PUCE-SI,26/04/2017 COMPILADORES $",0 CODE ENDS ENDS end codigo
  • 7.
     Compilar unprograma que permita comparar 2 números del 0 al 9. Código: name "flags" org 100h ; this sample shows how cmp instruction sets the flags. ; usually cmp instruction is followed by any relative ; jump instruction such as: je, ja, jl, jae... ; it is recommended to click "flags" and "analyze" ; for better visual expirience before stepping through this code. ; (signed/unsigned) ; 4 is equal to 4 mov ah, 4
  • 8.
    mov al, 4 cmpah, al nop ; (signed/unsigned) ; 4 is above and greater then 3 mov ah, 4 mov al, 3 cmp ah, al nop ; -5 = 251 = 0fbh ; (signed) ; 1 is greater then -5 mov ah, 1 mov al, -5 cmp ah, al nop ; (unsigned) ; 1 is below 251 mov ah, 1 mov al, 251 cmp ah, al nop ; (signed) ; -3 is less then -2 mov ah, -3 mov al, -2 cmp ah, al nop ; (signed) ; -2 is greater then -3 mov ah, -2 mov al, -3 cmp ah, al nop ; (unsigned) ; 255 is above 1 mov ah, 255 mov al, 1 cmp ah, al nop ; now a little game: game: mov dx, offset msg1 mov ah, 9 int 21h ; read character in al: mov ah, 1 int 21h
  • 9.
    cmp al, '0' jbstop cmp al, '9' ja stop cmp al, '5' jb below ja above mov dx, offset equal_5 jmp print below: mov dx, offset below_5 jmp print above: mov dx, offset above_5 print: mov ah, 9 int 21h jmp game ; loop. stop: ret ; stop msg1 db "enter a number or any other character to exit: $" equal_5 db " is five! (equal)", 0Dh,0Ah, "$" below_5 db " is below five!" , 0Dh,0Ah, "$" above_5 db " is above five!" , 0Dh,0Ah, "$" • Compilar un programa que permita sumar 10 valores asignados a un vector.
  • 10.
    Codigo: 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: 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
  • 11.
    loop print ; printbinary 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 ; wait for any key press: mov ah, 0 int 16h ret ; variables: vector db 5, 5, 5, 5, 5, 1, 1, 1, 1, 1 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 unprograma sugerido por usted, como propuesta adicional. CODIGO: name "hex-bin" org 100h ; load binary value: ; (hex: 5h) mov al, 00000101b ; load hex value: mov bl, 0ah ; load octal value: ; (hex: 8h) mov cl, 10o ; 5 + 10 = 15 (0fh) add al, bl ; 15 - 8 = 7 sub al, cl ; print result in binary: mov bl, al mov cx, 8 print: mov ah, 2 ; print function. mov dl, '0' test bl, 10000000b ; test first bit.
  • 13.
    jz zero mov dl,'1' zero: int 21h shl bl, 1 loop print ; print binary suffix: mov dl, 'b' int 21h ; wait for any key press: mov ah, 0 int 16h ret