Lenguaje Ensamblador CON EMU8086
Lenguaje Ensamblador CON EMU8086
Lenguaje Ensamblador CON EMU8086
CON EMU8086
1. LENGUAJE ENSAMBLADOR
2. Software EMU8086
El emu8086 es un emulador del microprocesador 8086 (Intel o AMD compatible) con assembler integrado.
Dado que en un entorno emulado de microprocesador no es posible implementar una interfaz real de
entrada/salida, el emu8086 permite interfacear con dispositivos virtuales y emular una comunicación con el
espacio de E/S.
Programa 01:
Org 100h
Mov ax, bl
Ret
ORG 100H
RET
Programa 02:
Org 100h
Mov ax, bx
Ret
Programa 03: Vamos a probar cargando valores de los sistemas numéricos, vamos a cargar el valor 27 decimal en
el registro AH.
Org 100h
Ret
Ret
Org 100h
Ret
Error
Org 100h
Ret
Org 100h
Ret
Programa 07: Se decide c Argar 2 valores → 15 decimal en el registro CH y 1101 en binario en el registro DL
Org 100h
mov CH, 15
Ret
Programa 08: Se decide cargar a AH el valor 28h, luego usando la interrupción mov copiar el valor AH al registro
CH
Org 100h
mov DH, AH
Ret
CARACTERES ASCII
Org 100h
Ret
Programa 10:
Org 100h
Ret
Nota:
[] → lo que haya en la dirección
Programa 11:
Org 100h
mov BL, 99
ret
Programa 12: Sumar los valores 5 y 4
ORG100h
moval,5 ;cargamosalregistroalelvalorde5
movbl,4 ;cargamosalregistroblelvalorde4
addal,bl ;adicionamos=>al=al+bl
ret
org100h
moval,11100b
movbl,0c1h
addal,bl
movbl,12
addal,bl
ret
1, 5, 9, 13, 11
org100h
moval,1
addal,al
movbl,2
addbl,bl
movcl,3
addcl,cl
movdl,4
adddl,dl
ret
Restas o diferencias:
Programa 15: Restar 2 de 5
org100h
moval,5
movbl,2
subal,bl
ret
org100h
moval,2
movbl,5
subal,bl
ret
Org 100h
mov al,12
inc al
ret
Org 100h
mov ah,12
inc ah
mov al,13
inc al
mov bh,14
inc bh
mov bl,15
inc bl
ret
➔ Operaciones decrementales
Org 100h
mov CX, 11
dec CX
ret
Programa 21: Correr el programa
Org 100h
Mov ax 101010001b
Dec ah
Mov bx,1131
Dec bh
Mov cx,0BABAh
Dec ch
Ret
MULTIPLICACIÓN Y DIVISIÓN
- Mul
- Div
Mul: la instrucción MUL realiza multiplicación (sin signo) entre AL y otro registro o un número. El resultado se
almacena en AX.
AX = AL*registro
MUL destino
Div: La instrucción DIV realiza la división (sin signo) entre AX y otro registro, quedando el resultado en AL y el módulo
en AH, es decir, el algoritmo es AL=AX/registro, AH=(módulo o residuo).
DIV destino
Org 100h
Mov dl,2
Mov al,4
Mul dl ; ax = al * dl
Ret
Org 100h
Mov DX 0AAAAh
Mul DX ; AX = AX*DX
; el resultado es 7554Eh
Ret
Org 100h
Mov AL,6
Mov BL,3
Ret
Mov AX,203
Mov BL,4
Ret
Programa 26: Correr el programa
Org 100h
Mov ah,12
Add dl,34o
Mul dl
Div dll
Ret
OPERADORES LÓGICOS
- NOT
- OR
- AND
- XOR
NOT:
➔ Lleva a cabo la negación bit por bit del operando destino. El resultado se guarda en el mismo operando
destino. Cambia los bits del operando por su complemento.
NOT destino
OR
➔ Or inclusivo lógico, la instrucción OR lleva a cabo, bit por bit, la disyunción inclusiva lógica de los dos
operandos. El resultado lo almacena en el destino.
OR destino,fuente
AND
➔ Operación lógica “and” a nivel de bit entre los operandos. El resultado se almacena en el destino.
AND destino,fuente
XOR
➔ Or exclusivo lógico, la instrucción OR lleva a cabo, bit por bit, la disyunción exclusiva lógica de los dos
operandos. El resultado lo almacena en el destino.
XOR destino,fuente
Programa 27: Correr el programa
org 100h
mov ax,1
not ax
mov bx,2
not bx
mov cx,3
not cx
mov dx,4
not dx
ret
org 100h
mov ah,0
mov al,0
or al,ah
mov bh,0
mov bl,1
or bl,bh
mov ch,1
mov cl,0
or cl,ch
mov dh,1
mov dl,1
or dl,dh
ret
org 100h
mov ah,0
mov al,0
and al,ah
mov bh,0
mov bl,1
and bl,bh
mov ch,1
mov cl,0
and cl,ch
mov dh,1
mov dl,1
and dl,dh
ret
Programa 30: Realizar la tabla de verdad de la compuerta XOR
org 100h
mov ah,0
mov al,0
xor al,ah
mov bh,0
mov bl,1
xor bl,bh
mov ch,1
mov cl,0
xor cl,ch
mov dh,1
mov dl,1
xor dl,dh
ret
org 100h
mov ah,0
mov al,0
not ah
or al,ah
mov bh,0
mov bl,1
not bh
or bl,bh
mov ch,1
mov al,0
not ch
or cl,ch
mov dh,1
mov dl,1
not dh
or dl,dh
ret
OTROS OPERADORES
- CMP
- NEG
CMP:
➔ Compara dos operandos.
CMP destino,fuente
NEG
NEG destino
org 100h
mov al,5
mov bl,5
cmp al,bl
ret
Programa 33: Correr el programa
org 100h
mov al,5
neg al
ret
org 100h
mov ax,0123h
mov dx,111000100b
cmp ah,dh
neg al
ret
org 100h
mov al,a
mov bl,b
mov cl,c
mov dl,d
ret
- observar
a db 01h
b db 02h
c db 03h
d db 04h
Programa 36: Correr el programa
org 100h
mov ah,variable1
mov al,variable2
mov bh,variable3
mov bl,variable4
mov cx,variable5
ret
- Observar
-
- variable1 db 017h
- variable2 db 0Ah
- variable3 db 0Dh
- variable4 db 01Ch
- variable5 dw 0Fah
org 100h
mov al,1
mov bl,2
mov cx,4
suma:
add al,bl
loop suma
ret
org 100h
mov cx,5
mov bx,1
mov dl,2
comienzo:
mov ax,bx
mul dx
mov bx,ax
loop comienzo
ret
Programa 38: Correr el programa
org 100h
call p1
add ax,1
ret
p1 proc near
mov ax,1234h
ret
endp
Programa 39: Correr el programa
org 100h
call p1
call p2
call p3
ret
p1 proc near
mov ax,0101h
mov cx,3
suma1:
add al,ah
loop suma1
ret
endp
p2 proc near
mov bx,0202h
mov cx,3
suma2:
add bl,bh
loop suma2
ret
endp
p3 proc near
mov dx,0303h
mov cx,3
suma3:
add dl,dh
loop suma3
ret
endp
Programa 39: Correr el programa
org 100h
mov ax,1000
mov cx,3
jmp bucle1
mov ax,2015h
mov bx,2016h
mov cx,2017h
bucle1:
mov ax,100000001b
mov bx,401o
add ah,al
add bh,bl
loop bucle1
ret
ACTIVIDAD 02
Desarrolle 10 ejercicios en ASEMBLER y correrlos en el simulador, realizar el informe en ms Word o PDF.