Unpack the Packed BCD Number - Unpack the Packed BCD Number code

Unpack the Packed BCD Number code

Posted on

Unpack the Packed BCD Number code

Write a Program to Unpack the Packed BCD Number in assembly Language.A digit BCD number is available in register AL. We have to unpack this BCD number i.e. we have to separate the BCD digits. e.g : If the number = 92 H then in unpack form the two digits will 02 H and 09 H. i.e. we have to mask the lower nibble, first and rotate four times to the right to get the MSB digit. Then to get the LSB digit mask the upper nibble. Display the result. Masking lower nibble means ANDing the number with OF0 to get MSB.

Algorithm to Unpack the Packed BCD Number

Step I         :   Initialize the data memory.

Step II        :   Load number into register AL.

Step III       :   Mask the lower nibble.

Step IV       :   Rotate 4 times left to make MSB digit = LSB.

Step V        :   Display the digit.

Step VI       :   Load number in AL.

Step VII      :   Mask upper nibble.

Step VIII      :   Display the result.

Step IX        :   Stop. 

Unpack+the+Packed+BCD+Number - Unpack the Packed BCD Number code

Program  to Unpack the Packed BCD Number

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 .

C:\programs>tasm unpack.asm

Turbo Assembler  Version 3.0  Copyright (c) 1988, 1991 Borland International

Assembling file:   unpack.asm

Error messages:    None

Warning messages:  None

Passes:            1

Remaining memory:  437k

C:\programs>tlink unpack

Turbo Link  Version 3.0 Copyright (c) 1987, 1990 Borland International

Warning: No stack

C:\programs>unpack

09 02

Source projectgeek.com