Question
Write a program in 8086 assembly language, which converts an input of 4 ASCII digits to an equivalent hexadecimal number. For example, an input string of 4 ASCII digita, xay "4", "5", "3" "2," will be converted to the hexadecimal equivalent of number 4532, which is 11B4, Explain the algorithm of the program.
Answer :
Word Count : 760
_____ _________ _________ ________ ___ ________ __________ ______ ______.
________ ______ ________ __________ _____ _______ __________ ________ _________.
______ ____ ___ ______ _____.
________ ___ ________ _____ _____ ____ _______ ___.
____ _______ ________ _______ _______ ________.
___ ________ ____ ____ ___ ______ __________.
______ ____ _______ ___ _________ ________ ___ __________ ________.
___ _______ ____ ___ _______.
_________ _________ ______ ________ _________ __________.
_____ __________ ________ ______ ________ ___ _______ ________ _______ ________ __________ ______.
___ ________ _________ ______ ____ ____ ___ ____.
_______ ________ _______ ____ ______ _____ ________ ___ ________ ___ ____.
_________ ___ ___ __________ ______ ______ ___ ________ ___ __________.
_______ _________ ___ _________ ____ ________ ______.
________ ______ ____ ______ __________ _______ ______ ________ __________.
__________ _______ _____ _____ ________ ___ _____ _________ _________ ______ ______ _________.
________ _______ ______ ____ ______.
_____ ____ ________ _______ ________ ________ ________ ____ ________.
______ _____ _____ _________ ___ ___ ___.
__________ _______ _____ ___ ________ _________ _______ ______.
_____ ______ __________ ______ ________ ______ _______ ________ __________ ___ _______.
____ ______ __________ ____ ___ ______ __________ __________ ___ ______.
_______ _________ ________ ______ _______ ___ ___ _______.
_________ ______ ___ _______ ______ _____ _____.
________ ______ _____ _______ _________ __________ _________ _________.
________ __________ _____ _________ _________ ______ _______ _______ ________ _____ _______.
____ _____ __________ __________ _______ _________ _________ ______ ______ _________.
_________ ____ ______ ___ ______ __________ __________ __________ _______ ________.
__________ _________ ______ ________ _______ __________ __________ ___.
__________ ________ __________ ___ ______ _______ ___ ______ ___.
________ _________ _______ _____ __________ ___ _______.
___ ________ ___ _______ _____ ___ ____ ___ ____ _________ ___ ____.
___ _____ _____ ____ _____ _________ _________ _____ __________.
______ _______ ______ _________ ____ _____ ____ __________ ____ _________.
_____ __________ ___ ___ ______.
____ _________ ____ __________ ________ ___ ________ ____.
____ ___ _________ __________ _____ ________ ______ _____ ____ __________ _____.
__________ ________ ______ _____ ________ ___ ______ ______ _________ ___ ________ ________.
_______ ________ _______ _____ __________ ________.
_______ _________ __________ ____ ________ _____.
_______ ____ __________ ___ _____ _________ ___ ________ _____ ___ __________.
_______ _______ ____ __________ __________ _______ ______ ___ _______ _____.
_________ __________ _____ _____ ____ ____.
_______ ____ __________ _________ ___ _____ ____ _____.
____ ____ ________ _________ ____.
______ _______ __________ ___ __________ ____ _____ __________ ____ _____ ______.
_________ ________ ________ ___ ____ ________ _________.
_____ ______ _________ ______ ______ _______ __________ _____ ______ ______ _____.
___ ___ _____ ____ ____ ____ __________ ________ ____ ___.
_____ __________ ___ ___ ___ __________ _________ _______.
_______ ________ ______ ___ _____ ___ ____ ______.
__________ _____ __________ _________ _______ _______ _________ _____.
____ ___ ____ ____ _____ _______ ________ ____.
_________ __________ ___ ___ _____ ____ ______.
________ ________ _________ _____ __________ ________ _________ _____ ____ _______.
__________ _______ __________ __________ _______ ________ _________ ______.
Skip in 10
To solve the problem of converting a 4-digit ASCII input string into an equivalent hexadecimal number in 8086 assembly language, we can break the task down into the following steps: ### Algorithm: 1. Input the 4 ASCII Digits: - Read 4 ASCII digits (e.g., '4', '5', '3', '2') one by one. Each digit represents a number in the range 0-9 or A-F (for hexadecimal). 2. Convert ASCII to Decimal: - The ASCII code for the digits '0'-'9' is in the range 0x30 to 0x39. To convert the ASCII digit to its actual decimal value, subtract 0x30 (48 in decimal). 3. Calculate the Hexadecimal Equivalent: - Start with an initial value of 0. - Multiply the accumulated value by 10 (shift the place value) and add the decimal value of each ASCII character. - After processing all 4 digits, the result will be the decimal equivalent of the number. 4. Convert Decimal to Hexadecimal: - Once we have the decimal value, we need to convert it into hexadecimal format. - The 8086 processor has specific instructions to perform the division and modulo operation, which can help extract the digits for the hexadecimal representation. 5. Display the Result: - Once the result is in hexadecimal form, display the result. ### 8086 Assembly Program: ```assembly .model small .stack 100h .data prompt db "Enter 4 digits: $" result db "The hexadecimal value is: $" input db 4 dup('0') ; Space for 4 ASCII digits hex_chars db "0123456789ABCDEF$" ; Hex characters for conversion .code main: ; Initialize the data segment mov ax, @data mov ds, ax ; Print the prompt message mov ah, 09h lea dx, prompt int 21h
___ _______ ______ ________ ______ _______ __________ ___ ______ ___._____ _________ _________ ________ ___ ________ __________ ______ ______.
________ ______ ________ __________ _____ _______ __________ ________ _________.
______ ____ ___ ______ _____.
________ ___ ________ _____ _____ ____ _______ ___.
____ _______ ________ _______ _______ ________.
___ ________ ____ ____ ___ ______ __________.
______ ____ _______ ___ _________ ________ ___ __________ ________.
___ _______ ____ ___ _______.
_________ _________ ______ ________ _________ __________.
_____ __________ ________ ______ ________ ___ _______ ________ _______ ________ __________ ______.
___ ________ _________ ______ ____ ____ ___ ____.
_______ ________ _______ ____ ______ _____ ________ ___ ________ ___ ____.
_________ ___ ___ __________ ______ ______ ___ ________ ___ __________.
_______ _________ ___ _________ ____ ________ ______.
________ ______ ____ ______ __________ _______ ______ ________ __________.
__________ _______ _____ _____ ________ ___ _____ _________ _________ ______ ______ _________.
________ _______ ______ ____ ______.
_____ ____ ________ _______ ________ ________ ________ ____ ________.
______ _____ _____ _________ ___ ___ ___.
__________ _______ _____ ___ ________ _________ _______ ______.
_____ ______ __________ ______ ________ ______ _______ ________ __________ ___ _______.
____ ______ __________ ____ ___ ______ __________ __________ ___ ______.
_______ _________ ________ ______ _______ ___ ___ _______.
_________ ______ ___ _______ ______ _____ _____.
________ ______ _____ _______ _________ __________ _________ _________.
________ __________ _____ _________ _________ ______ _______ _______ ________ _____ _______.
____ _____ __________ __________ _______ _________ _________ ______ ______ _________.
_________ ____ ______ ___ ______ __________ __________ __________ _______ ________.
__________ _________ ______ ________ _______ __________ __________ ___.
__________ ________ __________ ___ ______ _______ ___ ______ ___.
________ _________ _______ _____ __________ ___ _______.
___ ________ ___ _______ _____ ___ ____ ___ ____ _________ ___ ____.
___ _____ _____ ____ _____ _________ _________ _____ __________.
______ _______ ______ _________ ____ _____ ____ __________ ____ _________.
_____ __________ ___ ___ ______.
____ _________ ____ __________ ________ ___ ________ ____.
____ ___ _________ __________ _____ ________ ______ _____ ____ __________ _____.
__________ ________ ______ _____ ________ ___ ______ ______ _________ ___ ________ ________.
_______ ________ _______ _____ __________ ________.
_______ _________ __________ ____ ________ _____.
_______ ____ __________ ___ _____ _________ ___ ________ _____ ___ __________.
_______ _______ ____ __________ __________ _______ ______ ___ _______ _____.
_________ __________ _____ _____ ____ ____.
_______ ____ __________ _________ ___ _____ ____ _____.
____ ____ ________ _________ ____.
______ _______ __________ ___ __________ ____ _____ __________ ____ _____ ______.
_________ ________ ________ ___ ____ ________ _________.
_____ ______ _________ ______ ______ _______ __________ _____ ______ ______ _____.
___ ___ _____ ____ ____ ____ __________ ________ ____ ___.
_____ __________ ___ ___ ___ __________ _________ _______.
_______ ________ ______ ___ _____ ___ ____ ______.
__________ _____ __________ _________ _______ _______ _________ _____.
____ ___ ____ ____ _____ _______ ________ ____.
_________ __________ ___ ___ _____ ____ ______.
________ ________ _________ _____ __________ ________ _________ _____ ____ _______.
__________ _______ __________ __________ _______ ________ _________ ______.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.