data segment
data EndS
code segment
assume cs:code
start:
;org 100h
mov cx,4
repeat:
call decibin
call crlf
call binihex
call crlf
loop repeat
mov ah,4ch
int 21h
decibin proc near
pusu cx
mov bx,0
newchar:
mov al,1
int 21
sub al,30h
jl exit
cmp al,9d
jg exit
cbw
xchg ax,bx
mov cx,10d
mul cx
xchg ax,bx
add bx,ax
jmp newchar
exit:
pop cx
ret
decibin endp
binihex proc near
push cx
mov ch,4
rotate:
mov cl,4
rol bx,cl
mov al,bl
and al,0fh
add al,30h
cmp al,3ah
jl print
add al,7h
print:
mov dl,al
mov ah,02
int 21h
dec ch
jnz rotate
pop cx
ret
binihex endp
crlf proc near
mov dl,0dh
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21
ret
crlf endp
code EndS
End start