Thursday, February 10, 2011

Hexadecimal to ASCII



%OUT------------------------------------------------------------------------------------------------
%OUT- Converts a hex digit (0-9 & A-F) into its ASCII equivalent                                            
%out- input: Hex digit accepted from the user                                                                   
%out- output: ASCII equivalent of the hex digit is printed in hexadecimal form 
%out – author: Ayon and Ariyam                    
%OUT-----------------------------------------------------------------------------------------------

if1
include macrolib.lby
endif

.model small
.stack

.data

ip db "Enter a hex digit: ","$"                               ;a request to prompt the user for entering the binary no.
op db "  ASCII value:  ","$"                                   ;output message
heading db "***** HEX to ASCII *****","$"          ;a heading

.code


main proc
            clrscrn                                                            ;clearing the screen
            mov dx,0105h
            cursor                                                             ;setting up the cursor
            showmsg heading                                     ;displaying heading
           
            mov dx,0303h                                             ;pointing to next line
            cursor                                                             ;setting up the cursor
            showmsg ip                                                  ;prompt the user to enter the binary string
                       
            mov ah,01h
            int 21h
            mov bh,al                 ;ASCII value stored in AL is copied to BH to call macro 'output'
           
            showmsg op                        ;display output message, content of BH not hampered
            output                                  ;calling output macro
            exit
           
main endp
end main

No comments:

Post a Comment

Do you think this information useful or was not up to the mark? Comment if you have any advices or suggestions about the post.