Simulating AAA Instruction - Program for Simulating AAA Instruction

Program for Simulating AAA Instruction

Posted on

Objective 

Write a Program for Simulating AAA Instruction in assembly language.

Simulating AAA Instruction - Program for Simulating AAA Instruction

AAA instruction stands for ASCII Adjust for Addition. It is used whenever we want to add two decimal digits which are Representative in ASCII code, without masking off “3” in upper nibble. In our program AAA instruction is not available in the instruction set of 8086. So we will first accept the two digits in AL and BL registers. Then we will mask the upper nibble i.e. “3” from AL and BL register by ANDing  with 0F H, so that we will get LSB of two numbers. Then the two numbers are added.

Result of addition is in AL. We will check if the result is valid BCD. If addition > 9, then result is invalid BCD and to make it valid we will add 6. If result is valid, display the result.

Algorithm for Simulating AAA Instruction

Step I          :   Initialize the data segment.

Step II        :   Load number 1 in AL.

Step III       :   Load number 2 in BL.

Step IV       :   Mask the number 1 and store result in AL.

Step V         :   Mask number 2 and store result in BL.

Step VI       :   Add = number 1 + number 2.

Step VII     :   Check if addition < 9. If yes go to step IX. else go to step VIII.

Step VIII    :   Add 6 to make the result valid.

Step IX       :   Display the result.

Step X        :   Stop.

 

for+Simulating+AAA+Instruction - Program for Simulating AAA Instruction

Program for Simulating AAA Instruction

 

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 aaa.asm

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

Assembling file:   aaa.asm

Error messages:    None

Warning messages:  None

Passes:            1

Remaining memory:  438k

C:\programs>tlink aaa

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

Warning: No stack

C:\programs>aaa

11

Source projectgeek.com