如何用汇编语言实现十进制到二进制的转换
2个回答
展开全部
;输入不超过65535的10进制数,将其以二位的形式显示
CODE SEGMENT
ASSUME CS:CODE
ORG 100H
START:
JMP BBB
X DW 0
MSG1 DB 10,13,'please input a number:','$'
MSG2 DB 10,13,' ','$'
BBB:
PUSH CS
POP DS
LEA DX,MSG1
MOV AH,9
INT 21H
LEA BX,X
MOV AX,0
PUSH AX
AGAIN1:
MOV AH,1
INT 21H
CMP AL,13
JE LINE0
SUB AL,30H
MOV AH,0
MOV SI,AX
POP AX
MOV CL,10
MOV CH,0
MUL CX
ADD AX,SI
PUSH AX
JMP AGAIN1
LINE0:
POP AX
MOV WORD PTR[X],AX
LEA DI,MSG2
INC DI
INC DI
MOV CX,16
MOV AX,WORD PTR[X]
AGAIN2:
ROL AX,1
JC LINE1
MOV BYTE PTR [DI],'0'
JMP LINE2
LINE1:
MOV BYTE PTR [DI],'1'
LINE2:
INC DI
LOOP AGAIN2
LEA DX,MSG2
MOV AH,9
INT 21H
MOV AH,8
INT 21H
MOV AH,4CH
INT 21H
CODE ENDS
END START
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询