hexidec
segment
; 8-->2-->16
assume cs: hexidec
main
proc
far
start:
push
ds
sub
ax, ax
push
ax
repeat:
call
hexibin
; 8-->2
call
crlf
call
bintosixteen
; 2-->16
call
crlf
jmp
repeat
ret
main
endp
out1:
mov ax,4c00h
int 21h
;************************************************************
;八进制转换成二进制
hexibin
proc
near
mov
bx, 0
newchar:
mov
ah, 1
int
21h
cmp al,1bh
;如果按的是ESC则退出程序
jz
out1
sub
al, 30h
jl
exit
cmp
al, 8
jl
add_to
jmp
newchar
add_to:
mov
cl, 3
shl
bx, cl
mov
ah, 0
add
bx, ax
jmp
newchar
exit:
ret
hexibin
endp
;*********************************************************
;二进制转换成十六进制
bintosixteen
proc
mov cl,4
mov ch,4
output:
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp
al, 3ah
jl
print
add
al, 7
print:
mov dl,al
mov ah,2
int 21h
dec ch
jnz output
ret
bintosixteen
endp
;*********************************************************
;输出回车换行
crlf
proc
near
mov
dl, 0dh
mov
ah, 2
int
21h
mov
dl, 0ah
mov
ah, 2
int
21h
ret
crlf
endp
hexidec
ends
end
start
;和你的题目差不多了