;輸入不超過4294967295的10進位制數,將其以二位的形式顯示
CODE SEGMENT
ASSUME CS:CODE
ORG 100H
START:
JMP BBB
X DD 0
MSG1 DB 10,13,"please input a number:","$"
MSG2 DB 10,13," B","$"
BBB:
PUSH CS
POP DS
POP ES
LEA DX,MSG1
MOV AH,9
INT 21H
MOV WORD PTR X,0
MOV WORD PTR X+2,0
AGAIN1:
MOV AH,1
CMP AL,13
JE LINE0
SUB AL,30H
MOV AH,0
MOV SI,AX
SHL WORD PTR X,1
RCL WORD PTR X+2,1
MOV AX,WORD PTR X
MOV CX,WORD PTR X+2
ADD WORD PTR X,AX
ADC WORD PTR X+2,CX
ADD WORD PTR X,SI
ADC WORD PTR X+2,0
JMP AGAIN1
LINE0:
LEA DI,MSG2
INC DI
MOV CX,32
MOV BX,WORD PTR X+2
AGAIN2:
SHL AX,1
RCL BX,1
JC LINE1
MOV BYTE PTR [DI],"0"
JMP LINE2
LINE1:
MOV BYTE PTR [DI],"1"
LINE2:
LOOP AGAIN2
LEA DX,MSG2
MOV AH,8
MOV AH,4CH
CODE ENDS
END START
;輸入不超過4294967295的10進位制數,將其以二位的形式顯示
CODE SEGMENT
ASSUME CS:CODE
ORG 100H
START:
JMP BBB
X DD 0
MSG1 DB 10,13,"please input a number:","$"
MSG2 DB 10,13," B","$"
BBB:
PUSH CS
POP DS
PUSH CS
POP ES
LEA DX,MSG1
MOV AH,9
INT 21H
MOV WORD PTR X,0
MOV WORD PTR X+2,0
AGAIN1:
MOV AH,1
INT 21H
CMP AL,13
JE LINE0
SUB AL,30H
MOV AH,0
MOV SI,AX
SHL WORD PTR X,1
RCL WORD PTR X+2,1
MOV AX,WORD PTR X
MOV CX,WORD PTR X+2
SHL WORD PTR X,1
RCL WORD PTR X+2,1
SHL WORD PTR X,1
RCL WORD PTR X+2,1
ADD WORD PTR X,AX
ADC WORD PTR X+2,CX
ADD WORD PTR X,SI
ADC WORD PTR X+2,0
JMP AGAIN1
LINE0:
LEA DI,MSG2
INC DI
INC DI
MOV CX,32
MOV AX,WORD PTR X
MOV BX,WORD PTR X+2
AGAIN2:
SHL AX,1
RCL BX,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