ASCII-Binary conversion in Assembly Language
Write a Assembly program for ASCII-Binary conversion with proper output . First of all do ASCII-Gray conversion by Dividing the ASCII number by 2 until the quotient is 0 .
Algorithm for ASCII-Binary conversion
Step I : Get the number whose binary code equivalent is to be found.
Step II : Initialize count in CL = 08 H
Step III : Divide the number by 2 i.e. shift the number by 1 it to the left.
Step III : Display the bit shifted in carry.
Step IV : Decrement count
Step V : Check if count =0 ?
Step VI : If yes go to step VII else go to step III.
Step VII : Stop.
Program Code for ASCII-Binary conversion
1 |
.model small <br/> .data <br/> a db 0AH <br/> .code <br/> mov ax, @data ; Initialize data section <br/> mov ds, ax <br/> mov al, a ; Load number1 in al <br/> mov cl , 08H <br/> mov ah, 00h ; ah=00 <br/> up : shl al, 01h ; divide the number by 2 <br/> and SHL gives the same result <br/> mov bl, al <br/> mov al, 00H <br/> adc al, 30h <br/> mov dl, al <br/> mov ah, 02h <br/> int 21h <br/> mov al,bl <br/> dec cl <br/> jnz up <br/> mov ah, 4cH ; Terminate Program <br/> int 21H <br/> end |
How to Run this Program
For Running this program you should have installed Tasm on you computer . If you have not installed Tasm yet please install from Here .
Result : 0000 1010
Source projectgeek.com