STA SEGMENT STACK
DW 40H DUP(?)
TOP LABEL WORD
STA ENDS
DATA SEGMENT
CRLF DB 0DH,0AH,24H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,SS:STA,DS:DATA
MAIN PROC FAR
MOV AX,STA
MOV SS,AX
LEA SP,TOP
MOV AX,DATA
MOV DS,AX
MOV CX,5
XOR BX,BX
L1:MOV AH,1
INT 21H
CMP AL,0DH
JE L3
CMP AL,30H
JB L1
CMP AL,39H
JA L1
AND AX,0FH ;0000 0000 0000 1111
XCHG AX,BX ;交换两个数
MOV SI,10
MUL SI
JC L2 ;判断溢出,若溢出,则退出
ADD BX,AX
JC L2
LOOP L1 ;这里规定最多输五位的十进制数
L3:
MOV AH,9
LEA DX,CRLF ;回车换行
INT 21H
MOV CX,16
L5: XOR DX,DX
SHL BX,1
ADC DL,0
AND DL,1
OR DL,30H
MOV AH,2
INT 21H
LOOP L5
L2:MOV AH,4CH
INT 21H
MAIN ENDP
CODE ENDS
END MAIN