This document contains code snippets and summaries of programs written in Assembly language (EMU8086). It includes decompiled code for a "Hello World" program, a program to sum values in a vector, and code to compare two strings. The document discusses installing the EMU8086 assembler and decompiling and compiling Assembly programs.
7. PÁGINA 6
.code
main proc ;Inicia proceso
mov ax,seg saludo ;hmm ¿seg?
mov ds,ax ;ds = ax = saludo
mov ah,09 ;Function(print string)
lea dx,saludo ;DX = String terminated by "$"
int 21h ;Interruptions DOS Functions
;mensaje en pantalla
mov ax,4c00h ;Function (Quit with exit code (EXIT))
int 21h ;Interruption DOS Functions
main endp ;Termina proceso
end main
8. PÁGINA 7
Compilar un programa que permita comparar 2 números del 0 al 9.
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:
9. PÁGINA 8
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, 4, 5, 2, 1, 9, 1, 2, 5, 7
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
10. PÁGINA 9
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 QUE PERMITA SUMAR 10 VALORES ASIGNADOS EN UN
VECTOR
11. PÁGINA 10
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
12. PÁGINA 11
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, 4, 5, 2, 1, 9, 1, 2, 5, 7
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
14. PÁGINA 13
mov si, x
mov al, msg2[si]
cmp msg[si], al ;comparar letra por letra las cadenas, si uno no coincide mand
a directamente a fin y termina el programa
jne fin:
cmp msg[si], "$" ;si es el final y el programa llega aca, quiere decir que son
iguales
jz final:
inc x
loop comienzo
final:
mov dx, offset msg3
mov ah, 9
int 21h
fin:
ret
msg db "hello world $"
msg2 db "hello world $"
msg3 db "Son iguales $"
x dw 0