CR EQU 13
LF EQU 10
IMPRIMIR EQU 9
FIN EQU 4C00H
DOS EQU 21H
TAB EQU 09H
DATOS SEGMENT
ENCABEZADO DB 13,10,13,TAB,TAB, "=========="
DB 13,10,13,TAB,TAB,"PROGRAMA QUE IMPRIME NUMEROS HEXADECIMALES"
DB 13,10,13,TAB,TAB,"===============",13,10,13,"$"
DATOS ENDS
PILA SEGMENT STACK 'STACK'
DB 64 DUP ('0')
PILA ENDS
CODIGO SEGMENT
CEXA PROC NEAR
ASSUME CS:CODIGO, SS:PILA,DS:DATOS
ORG 100H
MOV AX,DATOS
MOV DS,AX
LEA DX,ENCABEZADO
CALL ESCRIBE
MOV CX, 200H
XOR DX,DX
CICLO:
CALL ESCRIBE_HEX
CALL ESCRIBE_CRLF
INC DX
LOOP CICLO
CALL SALIR
CEXA ENDP
ESCRIBE_HEX PROC NEAR
PUSH AX
PUSH CX
PUSH DX
OTRO_DIGITO:
PUSH CX
MOV CL,4
ROL DX,CL
CALL ESCRIBE_DIGITO_HEX
POP CX
LOOP OTRO_DIGITO
POP DX
POP CX
POP AX
RET
ESCRIBE_HEX ENDP
ESCRIBE_DIGITO_HEX PROC NEAR
PUSH AX
PUSH DX
AND DX,0FH
CMP DL,10
JAE ES_MAYOR_A_10
ADD DL,48
JMP IMPRIME_DIGITO
ES_MAYOR_A_10:
ADD DL,55
IMPRIME_DIGITO:
MOV AH,2
INT 21H
POP DX
POP AX
RET
ESCRIBE_DIGITO_HEX ENDP
ESCRIBE_CRLF PROC NEAR
PUSH AX
PUSH DX
MOV AH,2
MOV DL,13
INT 21H
MOV DL,10
INT 21H
POP DX
POP AX
RET
ESCRIBE_CRLF ENDP
ESCRIBE PROC
MOV AH,9
INT 21H
RET
ESCRIBE ENDP
SALIR PROC NEAR
MOV AX,FIN
INT DOS
RET
SALIR ENDP
CODIGO ENDS
END CEXA
No hay comentarios.:
Publicar un comentario