Addressing Modes - 1
Addressing Modes - 1
• Add R4, R2, R3 uses the Register mode for all three operands
• Absolute mode
• The operand is in a memory location; the address of this location is given
explicitly in the instruction
• Effective Address:
• The effective address is 0x1000, which is the value stored in BX.
• Memory Access:
• The instruction accesses the memory location 0x1000 and retrieves
the value stored there.
• Data Transfer:
• The value from memory location 0x1000 is moved into the AX
register.
• Detailed Steps
• Load Address:
• The register BX holds the address 0x1000.
• Access Memory:
• The CPU accesses the memory location 0x1000.
• Move Data:
• The data at memory location 0x1000 is moved into the AX register.
• Load R2, N
• Action: Load the size of the list into register R2.
• Purpose: R2 will hold the count of numbers to be summed.
• Clear R3
• Action: Initialize R3 to 0.
• Purpose: R3 will be used to accumulate the sum of the numbers.
• Move R4, #NUM1
• Action: Load the address of the first number in the list into register R4.
• Purpose: R4 will be used as a pointer to traverse the list.
• LOOP: Load R5, (R4)
• Action: Load the value at the address pointed to by R4 into register R5.
• Purpose: R5 will hold the current number to be added to the sum.
• Add R3, R3, R5
• Action: Add the value in R5 to R3 and store the result back in R3.
• Purpose: Accumulate the sum in R3.
• Add R4, R4, #4
• Action: Increment the pointer R4 by 4 bytes.
• Purpose: Move to the next number in the list (assuming each number is 4
bytes).
• Subtract R2, R2, #1
• Action: Decrement the counter R2 by 1.
• Purpose: Keep track of how many numbers are left to process.
• Branch_if_[R2]>0 LOOP
• Action: If R2 is greater than 0, branch back to the LOOP label.
• Purpose: Repeat the loop until all numbers have been processed.
• The effective address is the sum of the contents of registers Ri and Rj.
• X(Ri,Rj) In this case, the effective address is the sum of the constant X
and the contents of registers Ri and Rj