Instructions Formats & Addressing Modes
Instructions Formats & Addressing Modes
ADDRESSING MODES
COMPUTER INSTRUCTION
• Program:- A sequence of machine instructions.
• Machine Instruction: - A group of bits that tell the
computer to perform a specific operation.
Instruction formats
Operand
Indirect Addressing (1)
• Memory cell pointed to by address field contains
the address of (pointer to) the operand
• EA = (A)
— Look in A, find address (A) and look there for operand
• e.g. ADD (A)
— Add contents of cell pointed to by contents of A to
accumulator
• Pro-
—Large address space
– 2n where n = word length
• Cons-
—Two memory refe to fetch the operand Hence
slower
Indirect Addressing Diagram
• Assume a system memory extended to 64k words. So how can
we address these 64k memory cells?
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
Register Addressing (1)
• Operand is held in register named in address filed
• EA = R
• Similar to direct addressing except here the address field
refers to a register rather than a memory address.
• Limited number of registers
• The address field will have from 3 to 5 bits. Total of 8 or 32
registers can be referenced.
• pros.
— Very small address field needed
— Shorter instructions
— Faster instruction fetch
— No memory access
— Very fast execution
• Cons.
— Very limited Registers number and size
Register Addressing Diagram
Instruction
Opcode Register Address R
Registers
Operand
Register Indirect Addressing
• C.f. indirect addressing
• EA = (R)
• Operand is in memory cell pointed to by
contents of register R
• Large address space (2n)
• One fewer memory access than indirect
addressing
Register Indirect Addressing Diagram
Instruction
Opcode Register Address R
Memory
Registers
Registers
Indexed Addressing
— A = base, R = displacement
– EA = A + R
— Good for accessing arrays
– EA = A + R
– R++
Examples
• These are the values loaded into the accumulator for each
addressing mode.
17
Exercise
• The content of PC in the basic computer is 3AF (all
are in hexadecimal). The content of AC is 7EC3.
The content of memory at address 3AF is 932E. The
content of memory at address 32E is 09AC. The
content of memory at address 9AC is 8B9F.
What is the instruction that will be fetched and
executed next?
Show the binary operation that will be performed
in the AC when the instruction is executed.
Give the contents of registers PC,AR, DR, AC,
and IR in hexadecimal