Sunteți pe pagina 1din 8

UNIVERSIDAD NACIONAL DE INGENIERIA

FACULTAD DE ELECTROTECNIA Y COMPUTACIN


Dept. Sist. Digitales y Telecomunicaciones

ESTOS PROGRAMAS SON PARA PRACTICAR
Usando el EMU8086 (o el ensamblador MASM /TASM) editar, ensamblar, linkear y
ejecutar los siguientes programas:
Prog1.asm
.model small
.stack 100
.data

let1 db "Este es mi primer programa $"

.code
mov ax,@data ; Instrucciones para todo programa
mov ds,ax ;

mov dx,offset let1
mov ah,09h
int 21h

Exit: mov ax,4c00h
int 21h

END
Prog1b.asm
.model small
.stack 100
.data

let1 db "Este es mi primer programa $"
let2 db 10,"Cual mensaje deseas (1-3)$"

msg1 db "Mensaje UNO$"
msg2 db "Mensaje DOS$"
msg3 db "Mensaje TRES$"

.code
mov ax,@data ; Instrucciones para todo programa
mov ds,ax ;

mov dx,offset let1
mov ah,09h
UNIVERSIDAD NACIONAL DE INGENIERIA
FACULTAD DE ELECTROTECNIA Y COMPUTACIN
Dept. Sist. Digitales y Telecomunicaciones

int 21h

mov dx,offset let2
mov ah,09h
int 21h

Exit: mov ax,4c00h
int 21h

END
Prog1c.asm
.model small
.stack 100
.data

let1 db "Este es mi primer programa $"
let2 db 10,"Cual mensaje deseas (1-3)$"
let3 db 10,"Deseas terminar el programa (s/n)$"

msg1 db 10,"Mensaje UNO$"
msg2 db "Mensaje DOS$"
msg3 db "Mensaje TRES$"

.code
mov ax,@data ; Instrucciones para todo programa
mov ds,ax ;

mov dx,offset let1
mov ah,09h
int 21h

mov dx,offset let2
mov ah,09h
int 21h

lee_tecla:mov ah,01h
int 21h

mensaje1:cmp al,31h
jne mensaje2
mov ah,09h
mov dx,offset msg1
int 21h
UNIVERSIDAD NACIONAL DE INGENIERIA
FACULTAD DE ELECTROTECNIA Y COMPUTACIN
Dept. Sist. Digitales y Telecomunicaciones

jmp Exit

mensaje2:cmp al,32h
jne mensaje3
mov ah,09h
mov dx,offset msg2
int 21h
jmp Exit

mensaje3:cmp al,33h
jne Exit
mov ah,09h
mov dx,offset msg3
int 21h


Exit: mov ax,4c00h
int 21h

END
Prog1d.asm
.model small
.stack 100
.data

let1 db "Este es mi primer programa $"
let2 db 13,10,"Cual mensaje deseas (1-3)$"
let3 db 13,10,"Deseas terminar el programa (s/n)$"
let4 db 13,10,"*********** Error ***********$"


msg1 db 13,10,"Mensaje UNO$"
msg2 db 13,10,"Mensaje DOS$"
msg3 db 13,10,"Mensaje TRES$"

.code
mov ax,@data ; Instrucciones para todo programa
mov ds,ax ;

call CLRSCR

mov dx,offset let1
mov ah,09h
UNIVERSIDAD NACIONAL DE INGENIERIA
FACULTAD DE ELECTROTECNIA Y COMPUTACIN
Dept. Sist. Digitales y Telecomunicaciones

int 21h

ciclar2:mov dx,offset let2
mov ah,09h
int 21h

lee_tecla:mov ah,01h
int 21h

mensaje1:cmp al,31h
jne mensaje2
mov ah,09h
mov dx,offset msg1
int 21h
jmp Exit

mensaje2:cmp al,32h
jne mensaje3
mov ah,09h
mov dx,offset msg2
int 21h
jmp Exit

mensaje3:cmp al,33h
jne error
mov ah,09h
mov dx,offset msg3
int 21h




Exit: mov dx,offset let3
mov ah,09h
int 21h

mov ah,01h
int 21h

cmp al,'s'
je salir
cmp al,'S'
je salir
cmp al,'n'
je ciclar
UNIVERSIDAD NACIONAL DE INGENIERIA
FACULTAD DE ELECTROTECNIA Y COMPUTACIN
Dept. Sist. Digitales y Telecomunicaciones

cmp al,'N'
je ciclar

Error: mov dx,offset let4
mov ah,09h
int 21h
jmp Exit

ciclar: call CLRSCR
jmp ciclar2


salir: call CLRSCR
mov ax,4c00h
int 21h


;Procedimiento para limpiar pantalla
CLRSCR PROC NEAR
MOV AX,0600H
MOV BH,07H
MOV CX,0000H
MOV DX,184FH
INT 10H ;Interrupcion del BIOS
mov ah,02h
mov dx,0
mov bh,0
int 10h
RET
CLRSCR ENDP



END
Prog1 Mejorado
.model small
.stack 100
.data
let1 db 13,10,"Este es mi segundo programa de ejemplo $"
let2 db 13,10,"Cual mensaje deseas <1,2,3> $"
let3 db 13,10,"Deseas continuar (s/n) $"
UNIVERSIDAD NACIONAL DE INGENIERIA
FACULTAD DE ELECTROTECNIA Y COMPUTACIN
Dept. Sist. Digitales y Telecomunicaciones

let4 db 13,10,10,"******* error *****$"
msg1 db 13,10,10,"Mensaje UNO $"
msg2 db 13,10,10,"Mensaje DOS $"
msg3 db 13,10,10,"Mensaje TRES $"

.code
mov ax,@data ; Instrucciones para todo programa
mov ds,ax ;
inicio: call CLRSCR
mov dx,offset let1
mov ah,09h
int 21h
mov dx,offset let2
mov ah,09h
int 21h
mov ah,01h ;Funcion 1 de la int 21h
int 21h ;Leer una Tecla
mensaje1:
cmp al,31h ;compara si la tecla presionada fue el 1
jnz mensaje2
mov ah,09h
mov dx,offset msg1
int 21h
jmp salir
mensaje2:
cmp al,32h ;compara si la tecla presionada fue el 2
jnz mensaje3
mov ah,09h
mov dx,offset msg2
int 21h
jmp salir
mensaje3:
cmp al,33h ;compara si la tecla presionada fue el 3
jnz error
mov ah,09h
mov dx,offset msg3
int 21h
UNIVERSIDAD NACIONAL DE INGENIERIA
FACULTAD DE ELECTROTECNIA Y COMPUTACIN
Dept. Sist. Digitales y Telecomunicaciones

jmp salir
error: mov ah,09h
mov dx,offset let4
int 21h

salir: mov ah,09h
mov dx,offset let3
int 21h
mov ah,01h ;Funcion 1 de la int 21h
int 21h ;Leer una Tecla
cmp al,'S' ;compara el contenido de Al con el ascii de la 'S' y
jz inicio ;brinca si la comparacin fue cierta
cmp al,'s' ;lo mismo que el anterior pero con la 's' minscula
jz inicio
cmp al,'N'
jz Exit
cmp al,'n'
jz Exit
jmp error

Exit: call CLRSCR
mov ax,4c00h
int 21h
CLRSCR PROC NEAR
MOV AX,0600H
MOV BH,07H
MOV CX,0000H
MOV DX,184FH
INT 10H ;Interrupcion del BIOS
mov ah,02h
mov dx,0
mov bh,0
int 10h
RET
CLRSCR ENDP
END
UNIVERSIDAD NACIONAL DE INGENIERIA
FACULTAD DE ELECTROTECNIA Y COMPUTACIN
Dept. Sist. Digitales y Telecomunicaciones


Para copiar a un documento de word solo seleccinelo todo y haga un copy- paste.
Anexar a la Tarea integrantes que se juntaron para hacer la tarea, solo los que cooperaron, a
los que no participaron favor de no ponerlos. Gracias

S-ar putea să vă placă și