进制转化(从键盘接收一个4位的十进制数,将它转化为16进制并输出)

; 从键盘接收一个4位的十进制数,将它转化为16进制并输出
DATA SEGMENT
NUMDW 0
CRLFDB 0AH,0DH,24H
DATA ENDS

STACK SEGMENT PARA STACK
DW 128 DUP(?)
TOPLABEL WORD
STACK ENDS

CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
MAIN PROC FAR
START:
MOV AX,DATA
MOV DS,AX

MOV AX,STACK
MOV SS,AX
LEA SP,TOP

MOV CX,4
L1:MOV AH,1
INT 21H
SUB AL,30H
CBW
MOV BX,10
PUSH AX
MOV AX,NUM
MUL BX
POP BX
ADD AX,BX
MOV NUM,AX
LOOP L1
PUSH AX


MOV AH,9
LEA DX,CRLF
INT 21H

POP AX
XOR CX,CX
MOV BX,16
L2:XOR DX,DX
DIV BX
PUSH DX
INC CX
CMP AX,0
JNZ L2

L5:POP DX
CMP DL,10
JBL3
ADD DL,37H
JMP L4
L3:ADD DL,30H
L4:MOV AH,2
INT 21H
LOOP L5

MOV AH,4CH
INT 21H
CODE ENDS
MAIN ENDP
END START

    推荐阅读