Question

Write a program in 8086 assembly language, which converts a packed four-digit packed BCD number to equivalent four ASCII digits; for example, a packed BCD number “4367” stored in a word is converted to ASCII “4”, “3”, “6”, “7”. Explain the algorithm of the program.

13 Sep 2024
Answer :
Word Count : 1082

To convert a packed BCD (Binary-Coded Decimal) number to its ASCII equivalent in 8086 assembly language, we must first understand the structure of the packed BCD number and the corresponding ASCII codes for decimal digits.

In a packed BCD format, two decimal digits are stored in a single byte. Each digit takes 4 bits: the high nibble stores the first digit (0-9), and the low nibble stores the second digit (0-9). For instance, the packed BCD number 4367, represented as 0x43 and 0x67 in hexadecimal, would be stored in two bytes: 0x43 for the digits "4" and "3" and 0x67 for the digits "6" and "7".

To convert this packed BCD number into ASCII characters, each digit in the packed BCD must be extracted and then converted into its corresponding ASCII value. The ASCII values for the digits 0-9 range from 0x30 to 0x39. Thus, to convert the BCD digits to ASCII, we need to add 0x30 to the value of each BCD digit.

### Algorithm

1. Input the packed BCD number: This will be a 16-bit number where each byte holds two packed decimal digits.
2. Extract the first byte and separate the high and low nibbles: The high nibble represents the first BCD digit, and the low nibble represents the second BCD digit.
3. Convert each nibble into its ASCII equivalent: Add 0x30 to the value of the nibble to get the ASCII code.
4. Repeat the process for the second byte: Extract the high and low nibbles of the second byte and convert each to its ASCII equivalent.
5. Store the resulting ASCII characters: Store the ASCII codes in memory or output them as needed.

### Assembly Program

Here’s the 8086 assembly code to convert a packed BCD number to its ASCII equivalent:

```asm
.model small
.stack 100h

.data
    packedBCD dw 04367h   ; The packed BCD number: 0x43 (4,3) and 0x67 (6,7)
    asciiDigits db 4 dup(0)  ; Array to store the ASCII digits

.code
main:
    mov ax, @data        ; Initialize the data segment
    mov ds, ax

    ; Load the packed

______ _______ ___ ____ ________.
__________ _____ ___ _____ ____ __________ ______ _____ ________ ______ _______ ___.
_________ _________ ____ _______ _____ ____.
________ ________ ______ _________ ______ _______.
_____ ______ _____ ______ _______ _______ ______ ____ ________ ____.
_______ __________ _______ ____ ______.
___ __________ ______ __________ ______ _____ ____.
________ __________ ___ ____ ______ ______ ______ ___ ________ ______ ________.
______ ________ ________ _______ _______ ____ _______ __________ ________.
_________ ______ ________ ____ _______ _________ __________ ___ ____ ____ ________.
__________ __________ ________ _______ ___ _________ __________ ____ _________ _____ __________.
__________ __________ _______ ______ _________ ________.
______ ______ _________ ______ ______ ______ _____ _____ _____ _____.
________ ___ _______ ______ _______ ____ _____ ______ ___ ______ _________ ____.
_____ ______ _____ ______ ___ _____ ___.
_________ _______ __________ __________ _____ _____ ___ _______ ______ ____ ______.
_____ __________ _____ ______ ___ ___ _______ ____ ___ _______ __________ _____.
_________ _____ _______ ______ ___ _________ _____ __________ ___ ________ _______ ______.
____ _____ _______ ______ _______ ___.
_______ ______ _______ _______ __________ ______ __________ _______ ___ _______.
______ _______ _________ ________ ______ _______ __________ ___.
__________ _________ __________ _______ ______ __________.
______ _____ ________ ______ _____ _________ _______ ___ ______.
______ ________ ________ _____ _______ __________ ______ ____ _______ ____ _____ _________.
______ ____ ________ _______ ___ _____ _____ _______ __________.
_____ ___ __________ _________ ______ _________ ____ ________ _______ _______ ____ _____.
________ _________ ________ _____ ______ ________ ________ ________ ___ ___ _____ ___.
___ _____ __________ ________ _______ _____ ______ ____.
_____ ______ ______ ___ ______ ______ _________ _______.
_________ ________ _______ ___ _________ ____ ____ ________.
_________ _______ ____ ________ _____ ________ _____ _______ ___ _____ ____.
______ ___ ______ ________ ______ ___.
___ ___ ___ ______ _______ ________ ________ ____ ____ _______.
_____ __________ _____ _____ _______ ____ __________ ____ ___ ________ ___ _______.
_____ ___ _________ ___ _____ _________ _________ ______ _______ __________.
______ _________ ____ _______ _________ _______ ________ ________ _________ ____ ___ _____.
____ _______ ___ ________ ___ __________ _________ __________ ________.
_______ ______ ___ _______ ___ ________ ________ ______ ___ ________ ______.
_________ ___ ______ ________ __________ _____ ______ ____.
__________ _____ __________ ______ ___ ____ ____ ____ _______.
_________ ______ ____ ________ ___ _____.
_______ ____ _____ __________ ________ ___ _______ __________.
_____ ________ ________ ______ ________ ___ ____ _____.
_______ _______ ____ __________ __________ ____ ___ ___ ________ ______ ___ ___.
_______ __________ ________ _______ ______.
_________ _____ _______ _________ _________ __________.
_________ ________ ___ ____ ________ ______ _______ ___ _____ _____.
____ _____ ______ ________ ___ ____.
__________ _____ __________ ___ ______ ____ ___.
__________ _________ ___ _________ _________ ____ ____ _____.
__________ _______ ___ ____ __________ __________ __________.
_________ _______ ____ _________ _______ ______ _________ _______.
________ _______ _______ ____ __________ _______ _________ ________ ________ _____ ______.
__________ ____ ________ ____ _________ ______ ___ ___ _________.
_______ _______ _______ _______ ___ ________ ___ _______ ______ _________ _______ _________.
____ __________ _________ ________ ____ ____ ________ __________ _____ ___ ___ ______.
_______ _______ ________ ____ ________ _______ ________ ____ ________ _______.
______ ____ _____ ________ _______ ______ __________ ________.
_______ _____ _______ ____ __________ __________ ________ _________ _____ ____ _______ _________.
_____ _________ _________ _____ ______ _______ ___ _____ ________ _________.
_________ ____ _____ ________ ______ ____ __________ _________ _________.
___ ______ ___ ______ _________ __________ _______.
___ ________ _________ _______ _____ ____ _________ ________ __________ ________ __________ ________.
_______ _______ _____ ________ _________ _____ __________ _________ _____.
________ ____ _______ __________ ___ _______ ____ __________ __________ _______ ________ _________.
________ __________ _____ _______ ______ ____ ______ _________ ______ _____ ______ ______.
_____ ________ ________ _________ ___.
_______ ________ __________ ______ _______ _________.
_____ _______ ________ ________ _________ ________.
_______ _________ ____ _________ ______ _______ _____ ___ _____ ________ ___ _____.
_______ ______ _____ ________ ______ ___ _____ _____ ___.
_____ _________ _______ ___ ________ ___ _____ _________ _______.
_______ _______ ________ _______ _______ ______.
___ __________ ____ __________ _________ ________.
_____ ______ ___ _________ ____ _____ _____ ______ __________ _____ ______ _____.
_______ ____ _____ __________ _________ _____.
____ _____ _______ ________ ________ _________ _______ _________ ________ ________ __________.
__________ ____ _____ ______ __________ _________ ____ ________ _______.
_________ _______ _______ ________ _______ ____ _______ ______.
___ _______ ________ _____.
IGNOU ACADEMY
Your IGNOU journey, made easier.
  • Solved Assignments
  • Study Notes
  • Guess Papers
  • Question Papers
Skip in 10
Top
📞
Call Support Instant phone assistance IGNOU MCS 202 2024 2025 - Write a program in 8086 assembly language, which converts a packed fou | IGNOU Academy
→
🟢
WhatsApp Chat Fast live messaging
→
Email Us Business enquiries & support
→