Convert Hex to Binary
- .model small
- .stack 150h
- .data
- s0 db 0dh,0ah,"Input your Hex number :$"
- s1 db 0dh,0ah,"Convert into binary :$"
- s2 db 0dh,0ah,"The number of 1 bit is :$"
- aa db '0'
- .code
- main proc
- mov ax,@data
- mov ds,ax
- xor bx,bx
- mov cl,0
- mov ah,9
- lea dx,s0
- int 21h
- mov ah,1
- int 21h
- while:
- cmp al,0dh
- je endw
- cmp al,40h
- jg letter
- and al,0fh
- jmp shift
- letter:
- sub al,37h
- shift:
- add al,37h
- shl bx,cl
- or bl,al
- int 21h
- jmp while
- endw:
- mov ah,9
- lea dx,s1
- int 21h
- l1:
- shl bl,1
- jnc l4
- mov dl,'1'
- mov ah,2
- int 21h
- inc aa
- jmp l5
- l4:
- mov dl,'0'
- mov ah,2
- int 21h
- l5:
- inc cl
- cmp cl,8
- jne l1
- end:
- mov ah,9
- lea dx,s2
- int 21h
- mov ah,2
- mov dl,aa
- int 21h
- main endp
- end main
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment