比如bx=1234h 则输出字符0001001000110100b。
.MODEL SMALL
.STACK
.DATA
hexnumber dw 1234h
.CODE
MAIN PROC
mov ax,seg hexnumber
mov ds,ax
mov bx,hexnumber
call printbin
mov ax,4c00h
int 21h
MAIN ENDP
printbin proc
push ax
push bx
push cx
push dx
mov ah, 02h
mov cx,16
cc: shl bx,1
jc aa
mov dl,'0'
int 21h
jmp bb
aa: mov dl,'1'
int 21h
bb:loop cc
mov dl,"b"
int 21h
pop dx
pop cx
pop bx
pop ax
ret
printbin endp
end main
阅读(2065) | 评论(0) | 转发(0) |