Instruction Set Architectures
CS301
- Prof. Szajda
Instruction Set Architectures CS301 Prof. Szajda Instruction - - PowerPoint PPT Presentation
Instruction Set Architectures CS301 Prof. Szajda Instruction Categories Arithmetic w x = x + 1 Memory w mem[addr] = x; Control w for(int i = 0; i < 10 ; i++) Arguments to Arithmetic Operations Constant: x = x + 1
w Immediate addressing
§ Data appears in constant part of instruction
w Register direct or register addressing
§ Data is in register specified in instruction
w Direct addressing
§ Explicitly state address in instruction
w Register indirect
§ Register holds address of data in memor
4
associated with it where data is stored
w Smallest addressable component is a byte w Each cell is addressable by its byte location
0x0 0x7fffffff
0x7ff3fa8bc
associated with it where data is stored
w Smallest addressable component is a byte w Each cell is addressable by its byte location
0x0 0x7fffffff
0x5ffffd420
associated with it where data is stored
w Smallest addressable component is a byte w Each cell is addressable by its byte location
space in memory
0x0 0x7fffffff
0xf5fd780
8
w Push operands onto stack w Operations automatically take operands from top of stack (pop) w Push result on to stack
w 1 register for arithmetic (the accumulator) w 1 operand for memory
§ add addr // acc = acc + mem[addr] w Accumulator both source and destination
w More registers w Each register with dedicated purpose
§ Stack pointer § Array index w Has both accumulator-like instructions and MIPS-like instructions w Multiply/div accumulator separate from other accumulators
w All registers used for any purpose w Two Kinds:
§ Register-memory: one operand in memory § Load-store: all operands in registers
High Level Language Program Assembly Language Program Machine Language Program Hardware Compiler Assembler Machine Interpretation lw $15, 0($2) lw $16, 4($2) sw $16, 0($2) sw $15, 4($2) temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; 1000110001100010000000000000000 1000110011110010000000000000100 1010110011110010000000000000000 1010110001100010000000000000100 ALUOP[0:3] <= InstReg[9:11] & MASK
w Create instructions for specific operations
§ Square root
w Create composite instructions
§ Load then add then store
w Allow both memory and register addressing w Allow multiple operands in each instruction w Variable instruction length w Examples: VAX, Motorola 68K, Intel x86
w Include small number of basic instructions
§ Load, store, add, subtract
w Small number of operands permitted to instructions w Fixed instruction length w Examples: MIPS, PowerPC, SPARC, HP PA-RISC
16
Pentium 4: Note instruction length is variable!
I-type: used by immediate and data transfer functions R-type: used for register functions
d × Basei w 10112 = 1110
w 0 to 232-1 (4,294,967,295) 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 31 most significant bit least significant bit 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
w 0: positive w 1: negative
w 32b: 0 to 231-1 (2,147,483,647)
w 32b: -1 to -231 (-2,147,483,648)
§ -1: 32 1s § -231: 1(31 0s)
§ Positive + Positive = Negative
§ Negative + Negative = Positive
§ Positive - Negative = Negative
§ Negative - Positive = Positive
w Immediate fields are 16b but registers are 32b
w Copy most significant bit 16 times and prepend w 0000 0000 0000 0010
§ 0000 0000 0000 0000 0000 0000 0000 0010 § Positive #s have infinite number of preceding 0s
w 1111 1111 1111 1110
§ 1111 1111 1111 1111 1111 1111 1111 1110 § Negative #s have infinite number of preceding 1s