思路:
无论输入的是0123……abcdef,还是0123……ABCDEF都可以被解析为16进制字符
DATAS SEGMENT
crlf db 0dh,0ah,24h
DATAS ENDS
STACKS SEGMENT
;此处输入堆栈段代码
STACKS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS,SS:STACKS
START:
MOV AX,DATAS
MOV DS,AX
;此处输入代码段代码
mov bx,0
mov ch,4
input:
mov ah,1
int 21h
cmp al,30h
jl exit
cmp al,3ah
jl next
cmp al,'A'
jl exit
cmp al,'f'
jg exit
cmp al,'F'
jbe A10
cmp al,'a'
jge A00
jmp A20
A00:
sub al,20h ;小写变大写
A10:
sub al,7
next:
sub al,30h
mov cl,4
shl bx,cl
mov ah,0
add bx,ax
A20:
dec ch
jnz input
exit:
lea dx,crlf
mov ah,9
int 21h
mov ax,bx
mov si,8
mov cx,0
rotate:
xor dx,dx
div si
push dx
inc cx
cmp ax,0
jnz rotate
output:
pop dx
add dl,30h
mov ah,2
int 21h
loop output
last:
mov dl,'o' ;八进制后缀
mov ah,2
int 21h
MOV AH,4CH
INT 21H
CODES ENDS
END START