High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
Ensamblador emu 8086
1. Tarea en Clase de Compiladores
Nombre: Alexander Echeverría
Nivel: 5to Sistema
Fecha: 15-04-2014
Ejecutamos el ensamblador
Instalamos el ensamblador
2. Terminamos la Instalación
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
Al ejecutar el programa Hola Mundo nos sale en Ingles y con una serie de cambios en el código
lo cambiamos a español
3. Código del Ejemplo 1
name "hi-world"
; this example prints out "hello world!"
; 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
4. ; 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
5. ; 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 [0ah], ' '
mov [0ch], ','
mov [0eh], 'M'
mov [10h], 'u'
mov [12h], 'n'
mov [14h], 'd'
mov [16h], 'o'
6. 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
Ejemplo 2: Nombre completo del estudiante, Universidad, fecha y materia.
7. Código del ejercicio 2
name "hi-world"
; this example prints out "hello world!"
; 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
8. ; 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], 'A'
mov [04h], 'l'
mov [06h], 'e'
mov [08h], 'x'
mov [0ah], 'E'
mov [0ch], 'c'
mov [0eh], 'h'
mov [10h], 'e'
mov [12h], 'v'
mov [14h], 'e'
10. mov [4ah], 'C'
mov [4ch], 'o'
mov [4eh], 'm'
mov [50h], 'p'
mov [52h], 'i'
mov [54h], 'l'
mov [56h], 'a'
mov [58h], 'd'
mov [5ah], 'o'
mov [5ch], 'r'
mov [5eh], 'e'
mov [60h], 's'
; 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
11. Ejercicio 3 Comparación de numero con el 7
Código del ejercicio 3
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
12. 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
13. 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
14. int 21h
; read character in al:
mov ah, 1
int 21h
cmp al, '0'
jb stop
cmp al, '9'
ja stop
cmp al, '7'
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
15. msg1 db "enter a number or any other character to exit: $"
equal_5 db " es siete! (igual)", 0Dh,0Ah, "$"
below_5 db " es menor siete!" , 0Dh,0Ah, "$"
above_5 db " es mayor siete!" , 0Dh,0Ah, "$"
Ejercicio 4 Suma de 10 números
Código del Ejercicio 4
mov ah, 0
int 16h
ret
; variables:
vector db 5, 4, 5, 2, 1, 3, 4, 6, 1, 2,
m db 0
16. 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