Computer Architecture and Organization: Chapter 5: Instruction Sets
Computer Architecture and Organization: Chapter 5: Instruction Sets
Computer Architecture and Organization: Chapter 5: Instruction Sets
Computer Architecture
and Organization
• Data processing
• Data storage -main memory & registers
• Data movement – I/O instructions
• Program flow control – Test & branch instructions
• 3 addresses
• Operand 1, Operand 2, Result
• a = b + c;
• Not common
• Needs very long words to hold everything
• 2 addresses
• One address doubles as operand and result
• a=a+b
• Reduces length of instruction
• Requires some extra work
• Temporary storage to hold some results
• 0 (zero) addresses
• All addresses implicit
• Uses a stack
• Last-in-first-out
• e.g. push a
• push b
• add (0 address instruction)
• pop c
• c=a+b
• More addresses
• More complex instructions
• Fewer instructions per program
• Multiple general purpose registers
• Fewer addresses
• Less complex instructions
• More instructions per program
• Faster fetch/execution of instructions
• Addresses
• Numbers
• Integer/floating point
• Characters
• ASCII etc.
• Logical Data
• Bits or flags
• Data Transfer
• e.g. Move, POP/PUSH
• Arithmetic
• ADD,SUB,MUL
• Logical
• Bitwise operations e.g. AND, OR, XOR, shift, rotate
• Conversion
• Binary to decimal
• I/O
• System Control
• Transfer of Control
• Branch, interrupt call
• Privileged instructions
• CPU needs to be in specific state
• Kernel mode
• For operating systems use
• Example, access to process control blocks in a
multiprogramming system.
• Immediate
• Direct
• Indirect
• Register
• Register Indirect
• Displacement (Indexed)
• Stack
Instruction
Opcode Operand
Instruction
Opcode Address A
Memory
Operand
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
• No memory access
• Very fast execution
• Very limited address space
• Multiple registers helps performance
• Similar to direct addressing except this time address field
refers to register rather than a main memory address.
Instruction
Opcode Register Address R
Registers
Operand
Instruction
Opcode Register Address R
Memory
Registers
• EA = A + (R)
• Address field hold two values
• A = base value
• R = register that holds displacement
• or vice versa
Registers
• A holds displacement
• R holds pointer to base address
• EA = A + (R)
• e.g. segment registers in 80x86
• A = base
• R = displacement
• EA = A + (R)
• Good for accessing arrays
• EA = A + (R)
• (R)++
• Post-index
• Indexing performed after the indirection
• EA = (A) + (R)
• Pre-index
• Indexing performed before indirection
• EA = (A+(R))
Address Instruction
101 LDA 201
102 ADD 202
103 ADD 203
104 STA 204
201 DAT 2
202 DAT 3
203 DAT 4
204 DAT 0
ADD K
STA N
I DATA 2
J DATA 3
K DATA 4
N DATA 0
Computer Architecture
and Organization