|
|
#4
商殇2018-06-20 18:11
回复 3楼 Valenciax
CODE SEGMENT
ASSUME CS:CODE
BUFF DB 3,?,3 DUP(?)
ERRR DB 13,10,'error $'
LFCR DB 13,10,'$'
START: PUSH CS
POP DS
PUSH CS
POP ES
@0:
MOV AH,10
LEA DX,BUFF
INT 21H
LEA SI,BUFF
MOV CL,[SI+1]
MOV CH,0
CLD
ADD SI,2
MOV BL,0
@1:
LODSB
CMP AL,'0'
JB @10
CMP AL,'9'
JBE @9
CMP AL,'A'
JB @10
CMP AL,'F'
JBE @8
CMP AL,'a'
JB @10
CMP AL,'f'
JBE @7
JMP @10
@7:
SUB AL,'a'
ADD AL,10
JMP @11
@8:
SUB AL,'A'
ADD AL,10
JMP @11
@9:
SUB AL,'0'
JMP @11
@10:
LEA DX,ERRR
MOV AH,9
INT 21H
JMP @0
@11:
ROL BL,1
ROL BL,1
ROL BL,1
ROL BL,1
ADD BL,AL
LOOP @1
MOV AL,BL
MOV AH,0
PUSH AX
PUSH AX
MOV AH,9
LEA DX,LFCR
INT 21H
POP AX
CALL DSPAX10
POP AX
CALL DSPAX2
MOV AH,4CH
INT 21H
;================================
DSPAX2 PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSHF
XOR CX,CX
MOV BX,2
@DSPAX2_1:
XOR DX,DX
DIV BX
INC CX
OR DX,30H
PUSH DX
CMP AX,0
JNE @DSPAX2_1
MOV AH,2
@DISPAX2_2:
POP DX
CMP DL,3AH
JB @DISPAX2_3
ADD DL,7
@DISPAX2_3:
INT 21H
LOOP @DISPAX2_2
MOV DL,32
INT 21H
POPF
POP DX
POP CX
POP BX
POP AX
RET
DSPAX2 ENDP
;================================
DSPAX10 PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
PUSHF
XOR CX,CX
MOV BX,10
@DSPAX10_1:
XOR DX,DX
DIV BX
INC CX
OR DX,30H
PUSH DX
CMP AX,0
JNE @DSPAX10_1
MOV AH,2
@DISPAX10_2:
POP DX
CMP DL,3AH
JB @DISPAX10_3
ADD DL,7
@DISPAX10_3:
INT 21H
LOOP @DISPAX10_2
MOV DL,32
INT 21H
POPF
POP DX
POP CX
POP BX
POP AX
RET
DSPAX10 ENDP
;================================
CODE ENDS
END START
注释:要求是“以两个空格作为间隔”该程序是一个空格;
最后一句,“在下一行显示该十六进制数交换后的值”,该程序没有编辑。
要求举例:
输入:3A
输出:A3
速回谢谢!!!
|