0% found this document useful (0 votes)
10 views19 pages

Addressing Modes - 1

The document explains various addressing modes used in assembly language, including Register mode, Absolute mode, Immediate mode, Indirection, and Indexing. It details how operands are accessed and manipulated in memory, providing examples of instructions and their purposes. Additionally, it covers the calculation of effective addresses using constants and register values in Index mode.

Uploaded by

kanishkasp2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views19 pages

Addressing Modes - 1

The document explains various addressing modes used in assembly language, including Register mode, Absolute mode, Immediate mode, Indirection, and Indexing. It details how operands are accessed and manipulated in memory, providing examples of instructions and their purposes. Additionally, it covers the calculation of effective addresses using constants and register values in Index mode.

Uploaded by

kanishkasp2006
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Addressing Modes

Implementation of Variables and


Constants
• Register mode
• The operand is the contents of a processor register; the name of the
register is given in the instruction.

• 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

• Integer NUM1, NUM2, SUM

• The Absolute mode is used in the instruction


• Load R2, NUM1
which loads the value in the memory location NUM1 into register R2.
• Immediate mode—The operand is given explicitly in the instruction.
• For example, the instruction
• Add R4, R6, 200 immediate
• adds the value 200 to the contents of register R6, and places the result into
register R4. Using a subscript to denote the Immediate mode is not
appropriate in assembly languages.
• A common convention is to use the number sign (#) in front of the value to
indicate that this value is to be used as an immediate operand. Hence, we
write the instruction above in the form
• Add R4, R6, #200
Indirection and Pointers
Example
• MOV AX, [BX] means “move the value at the memory address
contained in BX into the register AX”
• Register content
• Suppose BX contains the value 0x1000.

• 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.

• Store R3, SUM


• Action: Store the final sum from R3 into the memory location labeled SUM.
• Purpose: Save the result of the summation.
Indexing and Arrays
• Index Mode Explained
• What is Index Mode?
• It’s a way to calculate the address of the data (operand) you want to access in
memory.
• How is the Address Calculated?
• You take a constant number (let’s call it X) and add it to the value stored in a register
(let’s call it Ri).
• Symbolic Representation:
• This is written as X(Ri), where:
• X is a fixed number provided in the instruction.
• Ri is the register holding a value.
• Effective Address (EA):
• The effective address is the actual memory address where the data is
located.
• It is calculated as: EA = X + [Ri]
• [Ri] means the value stored in the register Ri.
Example
• X = 5 (a constant value)
• Ri is a register that currently holds the value 10
• To find the effective address:

• Add X and the value in Ri: EA = 5 + 10 = 15


• So, the effective address where the data is located is 15.
the index register, R5, contains
the address of a memory
location, and the value X defines
an offset (also called a
displacement) from this address
to the location where the
operand is found

the constant X corresponds to


a memory address, and the
contents of the index register
define the offset to the
operand.
• a second register Rj may be used to contain the offset X, in which case
we can write the
• Index mode as (Ri,Rj)

• 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

You might also like