It Is The Mark of An Educated Mind To Be Able To Entertain A Thought Without Accepting It. Aristotle
It Is The Mark of An Educated Mind To Be Able To Entertain A Thought Without Accepting It. Aristotle
1. Block-code technique
To each of the 2K instructions a unique binary
bit pattern of length K is assigned.
An K-to-2K decoder can then be used to decode
all the instructions. For example,
instruction 0
instruction 1
instruction 2
3-to-8 instruction 3
3-bit Op-code decoder instruction 4
instruction 5
instruction 6
instruction 7
OP-CODE ENCODING
2. Expanding op-code technique
Consider an 4+12 bit instruction with a 4-bit op-code and three 4-
bit addresses.
Op-code Address 1 Address 2 Address 3
1
0
1/2
0
1
1/4 1
0 1
0 1 0 1 0 1 0 1
• Disadvantage:
– must decode instructions bit-by-bit, (can be slow).
– to decode, must have a logical representation of the encoded
tree, and follow branches as you decipher bits
– Fact is, most decoding is done in parallel
– Gives a speed advantage
ADDRESSING MODES
Immediate
Direct
Indirect
Register
Displacement (Indexed)
Stack
IMMEDIATE ADDRESSING
Operand is part of instruction
Operand = address field
e.g., ADD #5
Add 5 to contents of accumulator
5 is operand
No memory reference to fetch data
Fast
Limited range
DIRECT ADDRESSING
Address field contains address of operand
Effective address (EA) = address field (A)
e.g., 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 needed to work
out effective address
Limited address space (length of address
field)
DIRECT ADDRESSING DIAGRAM
Instruction
Opcode Address A
Memory
Operand
INDIRECT ADDRESSING
Memory cell pointed to by address
field contains the address of the
operand
EA = (A)
Look in A, find effective address and
look there for operand
E.g. ADD (A)
Add content of cell pointed to by content
of A to accumulator
INDIRECT ADDRESSING DIAGRAM
Instruction
Opcode Address A
Memory
Pointer to operand
Operand
REGISTER ADDRESSING
Operand is held in register
named in address field
EA = R
Limited number of registers
Very small address field needed
Shorter instructions
Faster fetch
DISPLACEMENT ADDRESSING
EA = A + (R)
Address field holds two values
A = base value
R = register that holds
displacement
or vice versa
See segmentation
STACK ADDRESSING
Operand is (implicitly) on top
of stack
e.g.
ADD Pop top two items from
stack and add and push result
on top
ADDRESSING MODES
inherent
an op-code indicates the address of its operand
register indirect
the register address in an instruction specifies the
address of its operand
indexed
an offset is added to a register to give the address of the
operand
relative
same as base-register mode except that the instruction
pointer is used as the base register
ADDRESSING MODES
Arithmetic
ADD, SUB, DIV, MUL
Logical
AND, OR, NOT, SHIFT, ROTATE
System-control
Test-And-Set
I/O
Separate I/O space input/output