Download Understanding Instruction Types, Operand Types, and Addressing Modes in ISA and more Summaries Architecture in PDF only on Docsity!
Instruction Set Architecture
Contents
Instruction
Instruction set
Number of Address
Addressing modes
Operand types
Operations types
Assembly programming
Instruction
Elements
Opcode: What to do Oprand(s): data source(s)/destination(s)
Representation
Binary bitsy
Symbolic representation Add, SUB, LOAD, etc E.G.: ADD X, Y
Instruction Length
Affected by
Memory size/organization, register numbers, bus
structure, etc
Flexibility vs. Implementation ComplexityFlexibility vs. Implementation Complexity
Memory–transfer consideration
Fixed vs. non-fixed instructions
Instruction Set
The collection of different instructions CPU can
understand and execute
Different instructions
Number of addresses/addressing modes
OO perand typesd t
Operation types
Number of Addresses
3 addresses
Operand 1, Operand 2, Result
e.g. a=b+c
2 address
One address doubles as operand and result
e g a = a+ce.g. a a+c
1 address
Implicit second address (accumulator)
0 address
All addresses are implicitly defined
Stack based computer
Stack Operation
Stack Organization
How Many Addresses
More addresses
More complex (powerful?) instructions
More registers
Inter-register operations are quicker
Fewer instructions per program
Fewer addresses
Less complex (powerful?) instructions
More instructions per program
Faster fetch/execution of instructions
Instruction Addressing
What
How is the address of an operand specified
Different addressing mode
Immediate
Direct
Indirect
Register
Register indirect
Displacement
Stack
Immediate Addressing
Operand is part of instruction
Operand = address field
Opcode Operand
Instruction
p
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 to work out effective
address
Limited address space
Indirect Addressing Diagram
Opcode Address A
Instruction
Memory
Pointer to operand
Operand
Register Addressing
Operand is held in register named in address
filed
EA = R
Limited number of registersLimited number of registers
Very small address field needed
Shorter instructions
Faster instruction fetch
Register Addressing (cont’d)
No memory access
Very fast execution
Very limited address space
M lti lMultiple registers helps performance i t h l f
Requires good assembly programming or
compiler writing
Compare with Direct addressing
Register Addressing Diagram
Opcode Register Address R
Instruction
Registers
Operand
Register Indirect Addressing
EA = (R)
Operand is in memory cell pointed to by
contents of register R
Compare with indirect addressingCompare with indirect addressing
Large address space ( n )
One fewer memory access than indirect
addressing
Register Indirect Addressing Diagram
Opcode Register Address R
Instruction
Memory
Registers
Pointer to Operand Operand
g
Stack Addressing
Operand is (implicitly) on top of stack
e.g.
ADD Pop top two items from stack
and addand add
Basic Addressing Mode Summary
Memory alignment
Addressing a data type large than byte must
be aligned
An access to an object of size S bytes at byte
address A is aligned if A mod s = 0.
0bxxxxxxxxxx0bxxxxxxxxxx byte (8bit) alignedbyte (8bit) aligned
0bxxxxxxxxx0 half word (16bit) aligned
0bxxxxxxxx00 word (32bit) aligned
0bxxxxxxx000 double word (64bit) aligned
Why aligned?
Misalignment causes implementation complications
Little/Big Endian
Little Endian:
put the least-significant byte first
Big Endian:
put the most significant byte firstput the most-significant byte first
Big/Little Endian Example
32bit data 0xFABC0123 at address 0xFF
0xFF20 0xFF21 0xFF22 0xFF Big Endian 0xFA 0xBC 0x01 0x
Little Endian 0x23 0x01 0xBC 0xFA
Operand Types
Numbers
Integer
Byte, short, word, long word
Unsigned/signed
Floating point
Float
Double
Characters
Logical Data
Branch
Unconditional branch
One of its operands is the address of next
instruction to be executed
Conditional branchConditional branch
Using status register
Execution of an instruction may change the status, e.g.
positive, negative, overflow, …
Multi-address format
Branch Example
Procedure Call
Procedure
Self-contained computer program incorporated
into a larger program
Economy and modularity
Procedure call
Call instruction
Branches to the procedure
Return instruction
Returns to the place where it was called
Call Instruction
Use register to save return address (next
instruction)
R Å PC + sizeof (instruction)
PCPC ÅÅ XX
Save the return address at the start of
precedure
X Å PC + sizeof (instruction)
PC Å X + sizeof (instruction)
Problems?
Nested Procedure Calls
Use of Stack
Last procedure call returns first (LIFO)
Pass parameters
Stack frame
MIPS Addressing
Can be big/little endian
All memory access must be aligned
Addressing modes
Register indirectRegister indirect
Ex: JR R
Displacement
Ex: ST R1, 100(R2)
Addressing modes encoded in opcode
Encoding MIPS64 ISA
Fixed length encoding – 32 bits
I-type instructions
R-type instructions
J-type instructionsJ type instructions
I-type instructions
I-Type instruction:
Op code rs rt immediate
6 bits 5 bits 5 bits 16 bits
Encodes: Loads and stores of bytes, half words, words, dwords Condition branch Example LW R1, 32(R4) 100011 00100 00001 0000000000100000
BENQ R0, R1, -
R-type instructions
R-Type instruction:
Op code rs rt rd func
6 bits 5 bits 5 bits 5 bits 11 bits
Register-Register ALU operations
rd Í rs func rt Function encodes data path operation: add, sub, slt, and Read/write special registers and moves
Example
DADD R2, R3, R 000000 00011 00100 00010 00000 100000
Source registers Destination register Op code variant
J-type instructions
J-Type instruction:
Op code immediate
6 bits 26 bits
Encodes:
Jump and jump & link
Trap and return from exception
Example
J 0x
MIPS Operations
Simple instructions
Load/store, add, subtract, multiply, divide, shift, …
Ex: DADD, DADDI, DADDU
Control FlowControl Flow
Compare equal/not equal, compare less, …
Ex: BEQZ, JR
Floating point
Load/store, add, subtract,…
Ex: ADD.D, ADD.S, MUL.D, MUL.S
Arithmetical/Logical
Floating point
Control Flow
MIPS Assembly Programming
“MIPS Assembly Language Programming”,
http://www.eecs.harvard.edu/~ellard/Courses/cs50-asm.pdf
Instructions
Instruction set
Number of Address
Addressing modes
Summary
Addressing modes
Operand types
Operations types
Assembly programming