Chapter 11 - Instruction Sets: Addressing Modes and Formats
Chapter 11 - Instruction Sets: Addressing Modes and Formats
Registers
Segmented Memory
In real-address mode, the IA-32 processor family (80386-pentium 4) can access 1MB
using 20 bit addresses in the range 0 to FFFFF. The problem: the 16-bit registers in the
8086 processor could not hold 20 bit addresses. The solution: segmented memory.
All of memory is divided into 64KB units called segments. Each segment begins at an
address having zero for its last hex digit, so that digit can be omitted when representing
the segment value. To reach a byte in a segment, an offset is used.
1
Addressing Modes
We have already discussed some addressing modes.
Q1: Can you name the addressing modes we have defined thus far?
Addressing Modes specify how to calculate the effective memory address of an operand
by using information held in registers and/or constants contained within a machine
instruction
It provides the means & ways to access various operands in an assembly language
program, and is completely architecture dependent.
1. Immediate
• Constant integer (8, 16, or 32 bits)
• Constant value is stored within the instruction
2. Register
• Name of a register is specified
• Register number is encoded within the instruction
3. Memory
• Reference to a location in memory
• Memory address is encoded within the instruction, or
• Register holds the address of a memory location
2
The most common addressing modes are:
1. Immediate Addressing
OPERAND = A
Example: ADD 5
Add 5 to contents of accumulator
Examples:
2. Direct Addressing
Address field contains address of operand
EA = A
Example: ADD A
• Add contents of cell A to accumulator
• Look in memory at address A for operand
3. Indirect Addressing
With direct addressing, length of address field is usually less than word length, thus
limiting address range.
EA = (A)
Parentheses are to be interpreted as meaning contents of.
3
4. Register Addressing
Similar to direct addressing. Only difference is that address field refers to a register
rather than a main memory address:
EA = R
Typically, an address field that references registers will have from 3 to 5 bits, so that a
total of from 8 to 32 general-purpose registers can be referenced.
Advantages
• Only a small address field is needed in instruction.
• No memory references are required.
Similar to indirect addressing. Only difference is that address field refers to a register
rather than a main memory address:
EA = (R)
Operand is in memory cell pointed to by contents of register R.
Advantages: basically same for indirect addressing. Register indirect addressing has a
large address space (2N). Register indirect addressing uses one less memory reference
than indirect addressing.
6. Displacement Addressing
4
7. Stack Addressing
Machine instructions need not include a memory reference but implicitly operate on top
of stack.
Example:ADD
• Pop top two items from stack and add
Write a program to copy 55H into RAM memory locations 40H to 45H using:
1. Direct addressing mode
2. Register indirect addressing mode without a loop
3. With a loop