DATA SEGMENT
BUF DW 1234H
BUF1 DW ? ;2进制数放到buf1内存单元
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
BEGIN: MOV AX,DATA
MOV DS,AX
MOV DX,BUF
CALL DISC
MOV AH,4CH
INT 21H
DISC PROC
XOR AX,AX
MOV BX,DX ; BX用来存在原数,每次循环4
MOV CX,4
NEXT: PUSH CX
MOV CL,4
ROL BX,CL
POP CX
MOV SI,BX
AND SI,000FH ; si用来保存每一次的“个位”
MOV DX,10
MUL DL
ADD AX,SI
LOOP NEXT
MOV BUF1,AX
RET
DISC ENDP
CODE ENDS
END BEGIN
4位bcd数转换为2进制数
时间: 2024-10-19 09:19:04