Comp Arch-B-1
Comp Arch-B-1
Machine Instructions
and Addressing Modes
Machine instruction
characteristics
• Instruction Sets: The complete collection of
machine or computer instructions that are
executed (understood) by a CPU.
– Determines the operation of the CPU.
– Usually represented by assembly codes
Elements Of a Machine Instruction
• Information of each instruction required by the CPU
for execution, and are specified by binary code:
Operation Code (Op-code): specifies the operation to
be performed. Ex. ADD, IN, MOV
Source Operand Reference: one or more source
operands. i.e. inputs for the operation.
Result Operand Reference: the result of the
operation.
Next Instruction Reference: tells the CPU where to
fetch the next instruction after the execution of this
instruction is complete.
• The source and result operands can be in one
of the three areas.
– Main or virtual memory: address must be
supplied.
– CPU register: the instruction must contain
the number of the desired register.
– I/O device: the I/O module and device must
be specified.
Instruction Representation
• Represented by a sequence of bits, and is
divided in to fields corresponding to the
elements.
• Example of a simple instruction format
• During instruction execution,
– instruction is read in to an Instruction
Register (IR).
– CPU extracts the data from various fields of
the instruction.
• Since it is difficult to deal with binary
representation of instructions, it is a common
practice to use a symbolic representation.
Instruction type Op-code Symbolic description
representation
Arithmetic 00000101 ADD M(X) Add M(X) AC; put the result in
AC
00000110 SUB M(X) Subtract M(X) from AC; put the
result in AC
Opcode Operand
Direct Addressing
• Address field contains address of operand
• Effective address (EA) = address field (A)
• Ex. ADD A
– Add contents of cell A to accumulator
– Look in memory at address A for operand
• Single memory reference to access data
• No additional calculations to work out effective
address
• Limited address space
Direct Addressing Diagram
Instruction
Opcode Address A
Memory
Operand
Indirect Addressing
• Memory cell pointed to by address field contains
the address of (pointer to) the operand
• EA = (A)
• Ex. ADD (A) ;Add contents of cell pointed to by
contents of A to accumulator
• Large address space; 2n where n = word length
• Multiple memory accesses to find operand
• Hence slower
Indirect Addressing Diagram
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
Register Addressing
• Operand is held in register named in address
filed; EA = R
• Limited number of registers
• Very small address field needed
– Shorter instructions
– Faster instruction fetch
• No memory access
• Very fast execution
• Very limited address space
Register Addressing Diagram
Instruction
Operand
Register Indirect Addressing
• Similar to indirect addressing
• Operand is in memory cell pointed to by
contents of register R; EA = (R)
• Large address space (2n)
• One fewer memory access than indirect
addressing
Register Indirect Addressing Diagram
Instruction
Registers
Registers