25-08-2017, 09:32 PM
ASSEMBLY LANGUAGE PROGRAMMING EXAMPLES
ASSEMBLY LANGUAGE PROGRAMMING .doc (Size: 450.5 KB / Downloads: 22)
Addition of two 8-bit numbers whose sum is 8-bits.
Explanation: This assembly language program adds two 8-bit numbers stored in two memory locations .The sum of the two numbers is 8-bits only.The necessary algorithm and flow charts are given below.
ALGORITHM:
Step1. : Initialize H-L pair with memory address X (say :8000).
Step2. : Clear accumulator.
Step3. : Add contents of memory location M to accumulator.
Step4. : Increment memory pointer (i.e. X=X+1).
Step5. : Add the contents of memory indicated by memory pointer to accumulator .
Step6. : Store the contents of accumulator in 8902.
Step7. : Halt
Example 3 : Decimal addition of two 8-bit numbers whose sum is 16 bits .
Explanation: Decimal addition of two 8-bit numbers is same as that of two 8-bit numbers program.Except that the use of DAA instruction.The first 8-bit number is stored in one memory location(say 8500) and the second 8-bit number is stored in the next location(8501).Add these two numbers and use the DAA instruction to get the result in decimal.Also check for carry.Store the LSB of the sum in one memory location(8502) and the MSB (carry) in the other location(8503).
ALGORITHM:
Step1. : Initialize H-L pair with memory address X (say : 8500).
Step2. : Clear Carry register C .
Step3. : Move contents of memory location M to accumulator.
Step4. : Increment memory pointer (i.e. 8501).
Step5. : Add the contents of memory indicated by memory pointer to accumulator .
Step6. : Apply the instruction DAA(Decimal adjust after addition)
Step 7 : Check for Carry
Step 8 : Store the sum in 8502.
Step8 : Store the Carry in 8503 location
Step 9 : Halt