Instruction Set Architectures Continued
Expanding Opcodes & Instructions
Expanding vs Fixed Opcodes Fixed Size Opcode: – Every type of instruction uses same opcode size – MIPS instruction format:
Fixed Opcodes Expanding Opcode: – Different instructions = different length opcodes
Expanding Opcodes Expanding Opcode : – Special opcode means : keep reading xxx = any pattern but all 1's X X X X X X X X X X X X
Expanding Opcode Expanding Opcode : – More efficient use of space – Intel : 0F = keep reading :
Expanding Opcodes ARM Expanding / Split OpCode
Expanding Instructions Every instruction does not have to be the same size:
Expanding Instructions Might decode based on instruction
Expanding Instructions Might decode based on instruction – Java bytecode – bipush #immediate : +0 bipush +1 immediate +2 next instruction
Expanding Instructions Might decode based on instruction – 3 possibilities:
Expanding Instructions Intel – 32 bit code : 1-6 bytes – 64 bit code : up to 15 bytes:
Addressing Modes
Addressing Addressing : the ways we are allowed to refer to values and locations
Addressing Immediate Addressing: Value hard coded in instruction Immediate
Addressing Modes Direct Addressing : – Instruction contains the memory address to use
Addressing Register Indirect Addressing: A register contains the address of data
Addressing Modes Register Indirect Addressing : – Pointers:
Addressing Register Indirect With Offset Addressing: Start with address in register, add immediate offset
Addressing Register Indirect With Index (Variable Offset): Start with address in register, add offset amount from another register R2
Addressing PC Relative Addressing: Literal value is added to current PC value Immediate
Addressing Memory Indirect Addressing: Register holds address of memory where address is R
Addressing Memory Indirect Addressing: Register holds address of memory where address is R
Memory Indirect Uses Easy to jump to nth record of regularly sized structure:
Memory Indirect Addressing Irregular structure needs lookup table to store start addresses of each item: Array of Pointers
Memory Indirect Addressing Memory indirect allows access to list[2] in one instruction:
Other Uses Jump tables used for – Efficient switch statements enum operation {LOAD, STORE, ADD}; Switch (operation) { case LOAD: LOAD code; break: case STORE: STORE code; break: case ADD : ADD code; break: }
Other Uses Jump tables used for – Efficient switch statements – OOP Function Lookup
Special Tricks
ARM Addressing Tricks ARM Provides 3 Varients of offset addresses – Temporarily add offset – Add offset and store changed address – Add change after using current value
Atomic Read/Write Multiprocessor systems have to allow for atomic series of actions Special instructions check/set a memory value in one step
Loop Instructions Loops get run a lot Combine – Increment, compare and branch into one instruction
ARM Thumb Mode Thumb Mode – 16 bit instructions