0% found this document useful (0 votes)
101 views3 pages

Set 3.4

The document outlines a program that adds two 4-byte integers stored in consecutive memory locations, with the result stored back in the first memory location. It provides an algorithm detailing the steps for the addition process, including register initialization and memory manipulation. Additionally, it includes before and after execution memory states and register contents, along with the corresponding assembly mnemonics and comments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views3 pages

Set 3.4

The document outlines a program that adds two 4-byte integers stored in consecutive memory locations, with the result stored back in the first memory location. It provides an algorithm detailing the steps for the addition process, including register initialization and memory manipulation. Additionally, it includes before and after execution memory states and register contents, along with the corresponding assembly mnemonics and comments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Set-3

3.4 Addition of 4-byte integer.


Write a program that adds a 4 byte integer stored in consecutive memory locations starting from C030H
beginning with lower order byte to another 4 byte integer stored in consecutive memory locations starting from
C060H beginning with lower order byte .Store the result in consecutive memory locations starting from C030H.
Algorithm:
1. Clear the contents of Reg A.
2. Initialize HL to C030H and DE to C060H as memory pointer.
3. Set Reg C to 04 as a counter.
4. Load the contents of DE pair to Accumulator.
5. Add along with carry the memory contents pointed by HL pair with Accumulator.
6. Store the result from the Accumulator to the memory location pointed by HL pair.
7. Increment the HL and DE register pair by 1.
8. Decrement the counter at Reg C by 1.
9. If the contents in Reg C are not equal to zero, then jump to step no.4.
10. Stop the execution.
Flow Chart:
Before Execution:

Memory Data (HEX) Memory Data (HEX)


Location (HEX) Location (HEX)
C030H 01 C060H 05
C031H 02 C061H 06
C032H 03 C062H 07
C033H 04 C063H 08

After Execution:

Memory Data (HEX) Memory Data (HEX)


Location (HEX) Location (HEX)
C030H 06 C060H 05
C031H 08 C061H 06
C032H 0A C062H 07
C033H 0C C063H 08

Before Execution:
Register Contents in Hexa Decimal

A B C D E F H L SPH SPL PCH PCL


F0 00 00 00 82 54 FF FE FF EB 00 00
Flag Contents:

D7 D6 D5 D4 D3 D2 D1 D0
S Z - AC - P - CY
0 1 0 1 0 1 0 0

After Execution:
Register Contents in Hexa Decimal

A B C D E F H L SPH SPL PCH PCL


0C FF 00 C0 64 54 C0 34 FF EB C0 13
Flag Contents:

D7 D6 D5 D4 D3 D2 D1 D0
S Z - AC - P - CY
0 1 0 1 0 1 0 0
MNEMONICS
ADDRESS LABEL HEX CODE COMMENT
OPCODE OPERAND

C000H START XRA A AF Clear Reg A to 0.

C001H LXIH C030H 21


Initialize HL as a memory pointer to
C002H 30
C030H.
C003H C0

C004H LXID C060H 11


Initialize DE as a memory pointer to
C005H 60
C060H.
C006H C0

C007H MVIC 04H 0E


Set the counter in Reg C to add 4-
bytes.
C008H 04
Load the contents from DE pair to
C009H UP LDAX D 1A
Accumulator.
Add Reg A along with carry to
C00AH ADC M 8E
memory location pointed by HL pair.
Move the contents of Accumulator to
C00BH MOV M, A 77
memory location pointed by HL pair.
C00CH INX H 23 Increment HL pair by 1.

C00DH INX D 13 Increment DE pair by 1.


Decrement the counter value at Reg C
C00EH DCR C 0D
by 1.
C00FH JNZ(UP) C009H C2
Jump if the contents of Reg C are not
C010H 09
zero to label UP.
C011H C0

C012H STOP RST 1 CF Stop the execution.

You might also like