ASCII-Binary conversion in Assembly Language
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
.model small .data a db 0AH .code mov ax, @data ; Initialize data section mov ds, ax mov al, a ; Load number1 in al mov cl , 08H mov ah, 00h ; ah=00 up : shl al, 01h ; divide the number by 2 and SHL gives the same result mov bl, al mov al, 00H adc al, 30h mov dl, al mov ah, 02h int 21h mov al,bl dec cl jnz up mov ah, 4cH ; Terminate Program int 21H 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 .
Leave a Reply