L 5-AddressingModes
L 5-AddressingModes
CL ← [54321H]
2) Direct Addressing
Operand
5. Register Relative Addressing
In this mode, the operand address is calculated using
one of the base registers and an 8 bit or a 16 bit
displacement.
Example:
Example:
address
This type of addressing mode often addresses a two-dimensional array
of memory data.
Base Relative-Plus-Index Addressing
In this mode, the address of the operand is calculated as the
sum of base register, index register and 8 bit or 16 bit
displacement.
Example:
MOV SI, 3;
MOV AL, My_array[3];
So AL holds value 4.
8. Indexed Addressing
• EA = Memory address + (R) (Index register)
– Address field references the main memory and
the referenced register contains a positive
displacement from that address
• Indexing technique is used to point or refer the
data stored in sequential memory locations one
by one.
• Efficient mechanism for performing iterative
operations
Combinations
• Postindex
• EA = (A) + (R)
Useful for stepping
through arrays in a
Auto- R1 <- R1 +M[R2]
Add R1, (R2)+ loop.
increment R2 <- R2 + d
R2 - start of array
d - size of an element
• Preindex
• EA = (A+(R))
Same as
autoincrement.
Auto- R2 <-R2-d Both can also be
Add R1,-(R2)
decrement R1 <- R1 + M[R2] used to implement
a stack as push and
pop
8. Stack Addressing
• Operand is (implicitly) on top of stack
• e.g.
—ADD Pop top two items from stack
and add
Stack Addressing
• Stack is linear array of reserved memory locations.
• Its associated with a pointer called Stack Pointer(SP)
• Stack pointer contains the address of Top of
Stack(TOS) where the operand is to be stored or
located.
– ie. address of operand is the contents of stack
pointer
• This addressing mode is the special case of register indirect
addressing where referenced register is a stack pointer.
• Usually stack grows in the direction of descending
addresses. ie. Starting from a high address and
progressing to lower one.
– In stack, SP is decremented before any items are
pushed on stack and Sp is incremented after any items
popped from stack
Summary
Check your understanding