Instruction Set Architecture

Size: px
Start display at page:

Download "Instruction Set Architecture"

Transcription

1 Instruction Set Architecture Arquitectura de Computadoras Arturo Díaz D PérezP Centro de Investigación n y de Estudios Avanzados del IPN adiaz@cinvestav.mx Arquitectura de Computadoras ISA- 1

2 Instruction Set... the attributes of a [computing] system as seen by the programmer, i. e., the conceptual structure and functional behavior, as distinct from the organization of the data flows and controls of logic design, and the physical implementation. Amdahl, Blaaw, Brooks, Arquitectura de Computadoras ISA- 2

3 Instruction Set Design software instruction set hardware Which is easier to change/design? Arquitectura de Computadoras ISA- 3

4 Instruction Set Architecture... the attributes of a [computing] system as seen by the programmer, i. e., the conceptual structure and functional behavior, as distinct from the organization of the data flows and controls of logic design, and the physical implementation. Amdahl, Blaaw, Brooks, Organization of programmable storage Data types & data structures: encodings and representations Instruction formats Instruction (or Operand Code) Set Modes of addressing and accessing data items and instructions Exceptional conditions Arquitectura de Computadoras ISA- 4

5 ISA: What Must be Specified? Instruction Fetch Instruction Decode Operand Fetch Execute Result Store Next Instruction Instruction Format or Encoding how is it decoded? Location of operands and result where other than memory? how many explicit operands? how are memory operands located? which can or cannot be in memory? Data type and Size Operations what are supported Successor instruction jumps, conditions, branches fetch-decode-execute is implicit! Arquitectura de Computadoras ISA- 5

6 Evolution of Instruction Sets Single Accumulator (EDSAC 1950) Accumulator + Index Registers (Manchester Mark I, IBM 700 series 1953 Separation of Programming Model from Implementation High-level Language Based (B ) Concept of a Family IBM General Purpose Register Machines Complex Instruction Sets (Vax, Intel ) Load/Store Architecture (CDC 6600, Cray ) RISC: MIPS, Sparc, 88000, IBM RS6000, Arquitectura de Computadoras ISA- 6

7 Basic ISA Classes Accumulator: 1 address add A acc acc + mem[a] 1+x address addx A acc acc + mem[a + x] Stack 0 address add tos tos + next General Purpose register 2 address add A B EA(A) EA(A) + EA(B) 3 address add A B C EA(A) EA(B) + EA(C) Load/Store 3 address add Ra Rb Rc Ra Rb + Rc load Ra Rb store Ra Rb Ra mem[rb] mem[rb] Ra Most real machines are hybrids of those Arquitectura de Computadoras ISA- 7

8 Comparing Number of Instructions Comparison: Bytes per instruction? Number of Instructions? Cycles per instruction? Code sequence for (C = A + B) for four classes of instruction sets: Stack Accumulator Register (register-memory) Register (load-store) Push A Load A Load R1,A Load R1,A Push B Add B Add R1,B Load R2,B Add Store C Store C, R1 Add R3,R1,R2 Pop C Store C,R3 Arquitectura de Computadoras ISA- 8

9 General Purpose Registers Dominate x all machines use general purpose registers Advantages of registers registers are faster than memory registers are easier for a compiler to use» e.g., (A*B) (C*D) (E*F) can do multiplies in any order vs. stack registers can hold variables» memory traffic is reduced, so program is sped up (since registers are faster than memory)» code density improves (since register named with fewer bits than memory location) Arquitectura de Computadoras ISA- 9

10 Caches vs. Registers Registers advantages Faster (no addressing mode, no tags) Deterministic (no misses) Can duplicate for two ports Short identifier (3-8 bits) Register disadvantages Must save/restore on procedure calls Can t take the address of a register Fixed size (FP, strings, structures) Compiler must control (?) Arquitectura de Computadoras ISA- 10

11 Caches vs. Registers (cont d) How many registers? More means + Hold operands longer (reducing memory traffic & potentially execution time) - Longer register specifiers (except with register windows) - Slow registers - More state slows context switches Arquitectura de Computadoras ISA- 11

12 MIPS I Registers Programmable storage 2 32 x bytes of memory 31 x 32-bit GPRs (R0 = 0) 32 x 32-bit FP regs (paired DP) HI, LO, PC r0 r1 r31 PC lo hi 0 Arquitectura de Computadoras ISA- 12

13 Typical Operations Data Movement Arithmetic Shift Logical Load (from memory) Store (to memory) memory-to-memory move register-to-register move input (from I/O device) output (to I/O device) push, pop (to/from stack) integer (binary + decimal) or FP Add, Subtract, Multiply, Divide shift left/right, rotate left/right not, and, or, set, clear Arquitectura de Computadoras ISA- 13

14 Typical Operations Control (Jump/Branch) Subroutine Linkage Interrupt Synchronization String Graphics (MMX) unconditional, conditional call, return trap, return test & set (atomic r-m-w) search, translate parallel subword ops (4 16bit add) little change since 1960 Arquitectura de Computadoras ISA- 14

15 Top 10 80x86 Instructions Rank instruction Integer Average Percent total executed 1 load 22% 2 conditional branch 20% 3 compare 16% 4 store 12% 5 add 8% 6 and 6% 7 sub 5% 8 move register-register 4% 9 call 1% 10 return 1% Total 96% Simple instructions dominate instruction frequency Arquitectura de Computadoras ISA- 15

16 Operation Summary Support these simple instructions, since they will dominate the number of instructions executed: load, store, add, subtract, move register-register, and, shift, compare equal, compare not equal, branch, jump, call, return; Arquitectura de Computadoras ISA- 16

17 Operands for ALU instructions ALU instructions combine operands (e.g. ADD) Number of explicit operands Two - destination equals one source Three - orthogonal Operands in registers or memory Any combination -- VAX» (orthogonal, but variable instr. formats) At least one register -- much of 360» (not orthogonal) All registers -- CRAY, DLX, RISCs» (orthogonal, but needs loads/stores) Arquitectura de Computadoras ISA- 17

18 Memory Addressing Since 1980 almost every machine uses addresses to level of 8-bits (byte) 2 questions for design of ISA: Since could read a 32-bit word as four loads of bytes from sequential byte addresses or as one load word from a single byte address,» How do byte addresses map onto words?» Can a word be placed on any byte boundary? Arquitectura de Computadoras ISA- 18

19 Addressing Objects: Endian Wars Big Endian: address of most significant byte = word address (xx00 = Big End of word) IBM 360/370, Motorola 68k, MIPS, Sparc, HP PA Little Endian: address of least significant byte = word address (xx00 = Little End of word) Intel 80x86, DEC Vax, DEC Alpha (Windows NT) Mode selectable becoming more common: PowerPC, MIPS R10000 msb little endian byte 0 lsb big endian byte 0 Arquitectura de Computadoras ISA- 19

20 Addressing Objects: Alignment Alignment: require that objects fall on address that is multiple of their size. Aligned Not Aligned Arquitectura de Computadoras ISA- 20

21 Alignment No restrictions Simpler software Hardware must detect misalignment and make 2 memory accesses expensive logic, slows down all references sometimes required for backward compatibility Restrictred alignment software must guarantee alignment hardware only detecs misalignment and traps trap handler does it Middle group misaligned data ok but requires multiple instructions compiler must skill know still trap on misaligned access Arquitectura de Computadoras ISA- 21

22 A typical RISC 32-bit fixed format instruction (3 formats) bit GPR (R0 contains zero, DP take pair) 3-address, reg-reg arithmetic instruction Single address mode for load/store: base+displacement no indirection Simple branch conditions Delay branch see: SPARC, MIPS MC88100, AMD2900, i960, i860, PARisc, DEC Alpha, Clipper, CDC 6600, CDC 7600, Cray-1, Cray-2, Cray-3,... Arquitectura de Computadoras ISA- 22

23 VAX-11 Byte 0 1 n m OpCode A/M A/M A/M Variable format, 2 and 3 address instruction 32-bit word size, 16 GPR (four reserved) Rich set of addressing modes (apply to any operand) Rich set of operations bit-field, stack, call, case, loop, string, poly, system) Rich set of data types (B, W, L, Q, O, F, D, G, H) Condition codes Arquitectura de Computadoras ISA- 23

24 VAX-11: Addressing Modes 1. Register Ri 2. Base + Displacement M[Ri + v] 3. Immediate v 4. Register Indirect M[Ri] 5. Direct (absolute) M[v] 6. Base + Index M[Ri + Rj] 7. Scaled Index M[Ri + Rj*d + v] 8. Autoincrement M[Ri++] 9. Autodecrement M[Ri--] 10. Memory Indirec M[ M[Ri] ] 11. [Indirection chains] Register File Memory Modes 1-4 account for 93 % of all operands on the VAX Arquitectura de Computadoras ISA- 24

25 Addressing Mode Usage 3 programs measured on machine with all address modes (VAX) --- Displacement: 42% avg, 32% to 55% --- Immediate: 33% avg, 17% to 43% --- Register deferred (indirect): 13% avg, 3% to 24% --- Scaled: 7% avg, 0% to 16% --- Memory indirect: 3% avg, 1% to 6% --- Misc: 2% avg, 0% to 3% 75% displacement & immediate 85% displacement, immediate & register indirect 75% 85% Arquitectura de Computadoras ISA- 25

26 Displacement Address Size? Int. Avg. FP Avg. 30% 25% 20% 15% 10% 5% 0% Address Bits Avg. of 5 SPECint92 programs v. avg. 5 SPECfp92 programs 1% of addresses > 16-bits bits of displacement needed Arquitectura de Computadoras ISA- 26

27 Immediate Size? 50% to 60% fit within 8 bits 75% to 80% fit within 16 bits Arquitectura de Computadoras ISA- 27

28 Addressing Summary Data Addressing modes that are important: Displacement, Immediate, Register Indirect Displacement size should be 12 to 16 bits Immediate size should be 8 to 16 bits Arquitectura de Computadoras ISA- 28

29 Generic Example of Instruction Format Widths Variable: Fixed: Hybrid: Arquitectura de Computadoras ISA- 29

30 Instruction Formats If code size is most important, use variable length instructions If performance is most important, use fixed length instructions Recent embedded machines (ARM, MIPS) added optional mode to execute subset of 16-bit wide instructions (Thumb, MIPS16); per procedure decide performance or density Some architectures actually exploring on-the-fly decompression for more density. Arquitectura de Computadoras ISA- 30

31 Instruction Format If have many memory operands per instruction and/or many addressing modes: =>Need one address specifier per operand If have load-store machine with 1 address per instr. and one or two addressing modes: => Can encode addressing mode in the opcode Arquitectura de Computadoras ISA- 31

32 MIPS Addressing Modes/Instruction Formats All instructions 32 bits wide Register (direct) op rs rt rd register Immediate op rs rt immed Base+index op rs rt immed Memory register + PC-relative op rs rt immed Memory Register Indirect? PC + Arquitectura de Computadoras ISA- 32

33 Most Popular ISA of all time: Intel 80x : Intel invents microprocessor 4004/8008, 8080 in : Gordon Moore realized one more chance for new ISA before ISA locked in for decades hired CS people in Oregon weren t ready in 1977 (CS people did 432 in 1980) started crash effort for 16-bit microcomputer 1978: 8086 dedicated registers, segmented address, 16 bit 8088; 8-bit external bus version of : IBM selects 8088 as basis for IBM PC 1980: 8087 floating point coprocessor: adds 60 instructions using hybrid stack/register scheme 1982: bit address, protection, memory mapping 1985: bit address, 32-bit GP registers, paging Arquitectura de Computadoras ISA- 33

34 Intel x86 (IA-32) 1989: & Pentium in 1992: faster + MP few instructions 1997: MMX multimedia extensions 200X: Superseded by IA-64 (Merced, McKinley, Itanium, etc.) Difficult to explain and impossible to love See H&P Appendix D.8 Eight 32-bit registers (EAX, EBX,..., but also ESP, EBP) Also 16- and 8-bit version (AX, AH, AL) Most instructions have two operands, one possibly from memory One super-duper addressing mode w/ effective address = base_reg + (index_reg * scaling_factor) + displacement Many formats: see H&P fig. D.8 Arquitectura de Computadoras ISA- 34

35 Intel MMX MultiMedia extension to IA-32 [Peleg & Weiser, IEEE Micro, 8/96] Multimedia data values often need much less than 32 bits But are organized in groups (e.g. red/green/blue) So in 64-bit FP registers: 2x32, 4x16, 8x8 E.g. ADDB (for byte) more more more MMX takes 16-element dot product (a 0 *b 0 + a 1 *b a 15 *b 15 ) from 200 to 16 instructions & from 76 to 12 cycles (6x) Arquitectura de Computadoras ISA- 35

36 Typical Operations Control (Jump/Branch) Subroutine Linkage Interrupt Synchronization String Graphics (MMX) unconditional, conditional call, return trap, return test & set (atomic r-m-w) search, translate parallel subword ops (4 16bit add) little change since 1960 Arquitectura de Computadoras ISA- 36

37 Control Instructions Conditional branches Jumps Procedure calls Procedure returns Taken or not taken? X Where is the target? X X Link return address Save or restore state X X X O.S. calls X X X O.O. returns X X X X Arquitectura de Computadoras ISA- 37

38 (1) Taken or not taken? Compare and branch instruction + No extra compare instruction + No state passed between instructions - Requires ALU operation - Restricts code scheduling opportunities Implicitly set condition codes (Z, N, V, C) + Can be set for free - Constrains code reordering - Extra state to save and restore Explicitly set condition codes (Z, N, V, C) + Can be set for free + Decouples branch/fetch from pipeline - Extra state to save and restore Arquitectura de Computadoras ISA- 38

39 (1) Taken or not taken?, cont. Condition in general-purpose register + No special state to save and implement but uses up a register - branch condition separated from branch logic in pipeline Some data for MIPS > 80 % of compares for branches use immediates > 80 % of these immediates are zero 50 % compares for branches are =0 or!= 0 Compromise used in MIPS Have branch-if = 0 and branch-if!= 0 Have compare instructions (r1=r2, r1!= r2, r1 < r2, r1 <= r2, etc.) With pipelining, can we predict whether taken? Statically? Dynamically? Arquitectura de Computadoras ISA- 39

40 (2) Where is the target? Could use Arbitrary Specifier? + Orthogonal and powerful - More bits to specify, more time to decode - branch execution and target separated in pipeline PC-relative with immediate + Position independence (helps linking), target computable in branch unit + Short immediate sufficient. MIPS word immediate: <= 4 bits: 47 % <= 8 bits: 94 % <= 12 bits: 100 % - Target must be known statically (to link) - Can t jump arbitrarily far - Other techniques are required for returns and distance jumps Arquitectura de Computadoras ISA- 40

41 (2) Where is the target?, cont. Register + Short specification + Can jump anywhere + Dynamic target okay (returns) - Extra instruction to load register (Vectored) Trap Critical for O.S. calls + Protection. - Implementation headache Common compromise (Conditional) branches (pc-rel) (Unconditional) jumps (pc-rel, reg) Procedure calls (pc-rel, reg) Procedure returns (reg) O.S. calls (trap) O.S. returns (reg) Arquitectura de Computadoras ISA- 41

42 (3) Link return address? Required for procedure calls and O.S. calls Implicit register + Fast, simple - SW must save register before next call - Surprise traps or interrups? Processor stack + Recursion supported directly - Complex instruction Explicit register - No important advantages over above - Register must be specified Many recent architectures use implicit register Arquitectura de Computadoras ISA- 42

43 (4) Save or restore state? What state? Procedure calls: registers O.S. calls: registers and PSW (incl. CCs) Hardware need not save registers Caller can save registers in use Callee can save registers it will use Hardware register save Which (IBM STM, VAX CALLS)? Is the above faster? Register windows Many recent architectures do no register saving or do implicit saving with register windows Arquitectura de Computadoras ISA- 43

44 MIPS: Register State 32 integer registers $0 ishardwaredto0 $31 is the return address register software convention for other registers 32 single-precision FP registers or 16 doubleprecision FP registers PC and other special registers Arquitectura de Computadoras ISA- 44

45 MIPS I Operation Overview Arithmetic Logical: Add, AddU, Sub, SubU, And, Or, Xor, Nor, SLT, SLTU AddI, AddIU, SLTI, SLTIU, AndI, OrI, XorI, LUI SLL, SRL, SRA, SLLV, SRLV, SRAV Memory Access: LB, LBU, LH, LHU, LW, LWL,LWR SB, SH, SW, SWL, SWR Arquitectura de Computadoras ISA- 45

46 Multiply / Divide Start multiply, divide MULT rs, rt MULTU rs, rt DIV rs, rt DIVU rs, rt Move result from multiply, divide MFHI rd MFLO rd Move to HI or LO MTHI rd MTLO rd Why not third field for destination? Registers (Hint: how many clock cycles for multiply or divide vs. add?) HI LO Arquitectura de Computadoras ISA- 46

47 Data Types Bit: 0, 1 Bit String: sequence of bits of a particular length 4 bits is a nibble 8 bits is a byte 16 bits is a half-word 32 bits is a word 64 bits is a double-word Character: ASCII 7 bit code UNICODE 16 bit code Decimal: digits 0-9 encoded as 0000b thru 1001b two decimal digits packed per 8 bit byte Integers: 2's Complement Floating Point: Single Precision Double Precision Extended Precision M x R E mantissa exponent base How many +/- #'s? Where is decimal pt? How are +/- exponents represented? Arquitectura de Computadoras ISA- 47

48 Operand Size Usage Doubleword 0% 69% Word 31% 74% Int Avg. Halfword 0% 19% FP Avg. Byte 7% 0% 0% 20% 40% 60% 80% Frequency of reference by size Support for these data sizes and types: 8-bit, 16-bit, 32-bit integers and 32-bit and 64-bit IEEE 754 floating point numbers Arquitectura de Computadoras ISA- 48

49 MIPS arithmetic instructions Instruction Example Meaning Comments add add $1,$2,$3 $1 = $2 + $3 3 operands; exception possible subtract sub $1,$2,$3 $1 = $2 $3 3 operands; exception possible add immediate addi $1,$2,100 $1 = $ constant; exception possible add unsigned addu $1,$2,$3 $1 = $2 + $3 3 operands; no exceptions subtract unsigned subu $1,$2,$3 $1 = $2 $3 3 operands; no exceptions add imm. unsign. addiu $1,$2,100 $1 = $ constant; no exceptions multiply mult $2,$3 Hi, Lo = $2 x $3 64-bit signed product multiply unsigned multu$2,$3 Hi, Lo = $2 x $3 64-bit unsigned product divide div $2,$3 Lo = $2 $3, Lo = quotient, Hi = remainder Hi = $2 mod $3 divide unsigned divu $2,$3 Lo = $2 $3, Unsigned quotient & remainder Hi = $2 mod $3 Move from Hi mfhi $1 $1 = Hi Used to get copy of Hi Move from Lo mflo $1 $1 = Lo Used to get copy of Lo Arquitectura de Computadoras ISA- 49

50 MIPS logical instructions Instruction Example Meaning Comment and and $1,$2,$3 $1 = $2 & $3 3 reg. operands; Logical AND or or $1,$2,$3 $1 = $2 $3 3 reg. operands; Logical OR xor xor $1,$2,$3 $1 = $2 $3 3 reg. operands; Logical XOR nor nor $1,$2,$3 $1 = ~($2 $3) 3 reg. operands; Logical NOR and immediate andi $1,$2,10 $1 = $2 & 10 Logical AND reg, constant or immediate ori $1,$2,10 $1 = $2 10 Logical OR reg, constant xor immediate xori $1, $2,10 $1 = ~$2 &~10 Logical XOR reg, constant shift left logical sll $1,$2,10 $1 = $2 << 10 Shift left by constant shift right logical srl $1,$2,10 $1 = $2 >> 10 Shift right by constant shift right arithm. sra $1,$2,10 $1 = $2 >> 10 Shift right (sign extend) shift left logical sllv $1,$2,$3 $1 = $2 << $3 Shift left by variable shift right logical srlv $1,$2, $3 $1 = $2 >> $3 Shift right by variable shift right arithm. srav $1,$2, $3 $1 = $2 >> $3 Shift right arith. by variable Arquitectura de Computadoras ISA- 50

51 MIPS data transfer instructions Instruction SW 500(R4), R3 SH 502(R2), R3 SB 41(R3), R2 LW R1, 30(R2) LH R1, 40(R3) LHU R1, 40(R3) LB R1, 40(R3) LBU R1, 40(R3) Comment Store word Store half Store byte Load word Load halfword Load halfword unsigned Load byte Load byte unsigned LUI R1, 40 Load Upper Immediate (16 bits shifted left by 16) LUI R5 R Arquitectura de Computadoras ISA- 51

52 When does MIPS sign extend? When value is sign extended, copy upper bit to full value: Examples of sign extending 8 bits to 16 bits: When is an immediate value sign extended? Arithmetic instructions (add, sub, etc.) sign extend immediates even for the unsigned versions of the instructions! Logical instructions do not sign extend Load/Store half or byte do sign extend, but unsigned versions do not. Arquitectura de Computadoras ISA- 52

53 Methods of Testing Condition Condition Codes Processor status bits are set as a side-effect of arithmetic instructions (possibly on Moves) or explicitly by compare or test instructions. ex: add r1, r2, r3 bz label Condition Register Ex: cmp r1, r2, r3 bgt r1, label Compare and Branch Ex: bgt r1, r2, label Arquitectura de Computadoras ISA- 53

54 Conditional Branch Distance Int. Avg. FP Avg. 40% 30% 20% 10% 0% Bits of Branch Dispalcement 25% of integer branches are 2 to 4 instructions Arquitectura de Computadoras ISA- 54

55 Conditional Branch Addressing PC-relative since most branches are relatively close to the current PC At least 8 bits suggested (±128 instructions) Compare Equal/Not Equal most important for integer programs (86%) LT/GE GT/LE EQ/NE 7% 7% 23% 40% 37% 86% Int Avg. FP Avg. 0% 50% 100% Frequency of comparison types in branches Arquitectura de Computadoras ISA- 55

56 MIPS Compare and Branch Compare and Branch BEQ rs, rt, offset if R[rs] == R[rt] then PC-relative branch BNE rs, rt, offset <> Compare to zero and Branch BLEZ rs, offset BGTZ rs, offset > BLT < BGEZ >= if R[rs] <= 0 then PC-relative branch BLTZAL rs, offset if R[rs] < 0 then branch and link (into R 31) BGEZAL >=! Remaining set of compare and branch ops take two instructions Almost all comparisons are against zero! Arquitectura de Computadoras ISA- 56

57 MIPS jump, branch, compare instructions Instruction Example Meaning branch on equal beq $1,$2,100 if ($1 == $2) go to PC Equal test; PC relative branch branch on not eq. bne $1,$2,100 if ($1!= $2) go to PC Not equal test; PC relative set on less than slt $1,$2,$3 if ($2 < $3) $1=1; else $1=0 Compare less than; 2 s comp. set less than imm. slti $1,$2,100 if ($2 < 100) $1=1; else $1=0 Compare < constant; 2 s comp. set less than uns. sltu $1,$2,$3 if ($2 < $3) $1=1; else $1=0 Compare less than; unsigned numbers set l. t. imm. uns. sltiu $1,$2,100 if ($2 < 100) $1=1; else $1=0 Compare < constant; unsigned numbers jump j go to Jump to target address jump register jr $31 go to $31 For switch, procedure return jump and link jal $31 = PC + 4; go to For procedure call Arquitectura de Computadoras ISA- 57

58 Signed vs. Unsigned Comparison R1= R2= R3= After executing these instructions: two two two slt r4,r2,r1 ; if (r2 < r1) r4=1; else r4=0 slt r5,r3,r1 ; if (r3 < r1) r5=1; else r5=0 sltu r6,r2,r1 ; if (r2 < r1) r6=1; else r6=0 sltu r7,r3,r1 ; if (r3 < r1) r7=1; else r7=0 What are values of registers r4 - r7? Why? r4 = ; r5 = ; r6 = ; r7 = ; Arquitectura de Computadoras ISA- 58

59 Calls: Why Are Stacks So Great? Stacking of Subroutine Calls & Returns and Environments: A: CALL B B: CALL C C: RET RET A A B A B C A B A Some machines provide a memory stack as part of the architecture (e.g., VAX) Sometimes stacks are implemented via software convention (e.g., MIPS) Arquitectura de Computadoras ISA- 59

60 Memory Stacks Useful for stacked environments/subroutine call & return even if operand stack not part of architecture Stacks that Grow Up vs. Stacks that Grow Down: Next Empty? SP Last Full? c b a How is empty stack represented? Little --> Big/Last Full POP: Read from Mem(SP) Decrement SP inf. Big grows up 0 Little 0 Little grows down inf. Big Little --> Big/Next Empty Memory Addresses POP: Decrement SP Read from Mem(SP) PUSH: Increment SP Write to Mem(SP) PUSH: Write to Mem(SP) Increment SP Arquitectura de Computadoras ISA- 60

61 Call-Return Linkage: Stack Frames High Mem ARGS Callee Save Registers Reference args and local variables at fixed (positive) offset from FP (old FP, RA) FP SP Local Variables Grows and shrinks during expression evaluation Low Mem Many variations on stacks possible (up/down, last pushed / next ) Compilers normally keep scalar variables in registers, not memory! Arquitectura de Computadoras ISA- 61

62 MIPS: Software conventions for Registers 0 zero constant 0 1 at reserved for assembler 2 v0 expression evaluation & 3 v1 function results 4 a0 arguments 5 a1 6 a2 7 a3 8 t0 temporary: caller saves... (callee can clobber) 15 t7 16 s0 callee saves... (callee must save) 23 s7 24 t8 temporary (cont d) 25 t9 26 k0 reserved for OS kernel 27 k1 28 gp Pointer to global area 29 sp Stack pointer 30 fp frame pointer 31 ra Return Address (HW) Arquitectura de Computadoras ISA- 62

63 MIPS / GCC Calling Conventions fact: addiu $sp, $sp, -32 sw $ra, 20($sp) sw $fp, 16($sp) addiu $fp, $sp, sw $a0, 0($fp)... lw $31, 20($sp) lw $fp, 16($sp) addiu $sp, $sp, 32 jr $31 First four arguments passed in registers. FP SP ra FP SP ra FP SP ra old FP ra old FP low address Arquitectura de Computadoras ISA- 63

64 Details of the MIPS instruction set Register zero always has the value zero (even if you try to write it) Branch/jump and link put the return addr. PC+4 or 8 into the link register (R31) (depends on logical vs physical architecture) All instructions change all 32 bits of the destination register (including lui, lb, lh) and all read all 32 bits of sources (add, sub, and, or, ) Immediate arithmetic and logical instructions are extended as follows: logical immediates ops are zero extended to 32 bits arithmetic immediates ops are sign extended to 32 bits (including addu) The data loaded by the instructions lb and lh are extended as follows: lbu, lhu are zero extended lb, lh are sign extended Overflow can occur in these arithmetic and logical instructions: add, sub, addi it cannot occur in addu, subu, addiu, and, or, xor, nor, shifts, mult, multu, div, divu Arquitectura de Computadoras ISA- 64

65 Delayed Branches li r3, #7 sub r4, r4, 1 bz r4, LL addi r5, r3, 1 subi r6, r6, 2 LL: slt r1, r3, r5 In the Raw MIPS, the instruction after the branch is executed even when the branch is taken? This is hidden by the assembler for the MIPS virtual machine allows the compiler to better utilize the instruction pipeline (???) Arquitectura de Computadoras ISA- 65

66 Branch & Pipelines Time li r3, #7 sub r4, r4, 1 execute ifetch execute bz r4, LL ifetch execute Branch addi r5, r3, 1 ifetch execute Delay Slot LL: slt r1, r3, r5 Branch Target ifetch execute By the end of Branch instruction, the CPU knows whether or not the branch will take place. However, it will have fetched the next instruction by then, regardless of whether or not a branch will be taken. Why not execute it? Arquitectura de Computadoras ISA- 66

67 Filling Delayed Branches Branch: IF execute successor even if branch taken! Then branch target or continue DEC & OP fetch Execute IF DEC & OP fetch Execute IF Single delay slot impacts the critical path Compiler can fill a single delay slot with a useful instruction 50% of the time. try to move down from above jump move up from target, if safe add r3, r1, r2 sub r4, r4, 1 bz r4, LL NOP... LL: add rd,... Is this violating the ISA abstraction? Arquitectura de Computadoras ISA- 67

68 Miscellaneous MIPS I instructions break A breakpoint trap occurs, transfers control to exception handler syscall A system trap occurs, transfers control to exception handler coprocessor instrs. Support for floating point TLB instructions Support for virtual memory: discussed later restore from exception Restores previous interrupt mask & kernel/user mode bits into status register load word left/right Supports misaligned word loads store word left/right Supports misaligned word stores Arquitectura de Computadoras ISA- 68

69 MIPS: Instruction Set Format load/store architecture with 3 explicit operands (ALU ops) fixed 32-bit instructions 3 instruction formats» R-Type» I-Type» J-Type 6 instruction set groups:» load/store - data movement operations» computational - arithmetic, logical, and shift operations» jump/branch - including call and returns» coprocessor - FP instructions» coprocessor0 - memory management and exception handling» special - accessing special registers, system calls, breakpoint instructions, etc. Arquitectura de Computadoras ISA- 69

70 R2000/3000 Instruction Formats R-type (register) e.g. add $8, $17, $18 # $8 = $17 + $ OpCode rs rt rd shamt funct Arquitectura de Computadoras ISA- 70

71 R2000/3000 Instruction Formats I-type (immediate) e.g. addi $8, $17, -44 # $8 = $17-44 lw $8, -44($17) # $8 = M[$17-44] beq $17, $8, label # if( $8 == $17) go to label: OpCode rs rt immediate op Arquitectura de Computadoras ISA- 71

72 R2000/3000 Instruction Formats J-type (jump) e.g. jump label # call label: ; $31 = $pc OpCode target Arquitectura de Computadoras ISA- 72

73 Bhandarkar and and Clark: RISC vs. CISC Compares the VAX 8700 vs MIPS M/2000 (R3000 chip) Combines three fractors: Architecture Implementation Compilers and OS Argues that: Implementation effects are second order Compilers are similar RISCs are better than CISCs Is it a fair comparison of RISCs vs CISCs? Arquitectura de Computadoras ISA- 73

74 Bhandarkar and Clark, cont. RISC factor Instr Risc Factor = CPI vax CPI Instr vax mips mips Bechmark Inst. Ratio CPI MIPS CPI VAX Ratio RISC factor spice2g matrix nasa fpppp tomcatv dudoc espresso eqntott li geo. mean Arquitectura de Computadoras ISA- 74

75 Bhandarkar and Clark, cont. Compensation Factors Increase VAX CPI but decrease VAX instruction count Increase MIPS instruction count Example 1: Loads and stores vs. operand specifiers Example 2: Necessary complex operations, e.g. loop branches Factors favoring VAX Big immediate values Not-taken branches incur no delay Arquitectura de Computadoras ISA- 75

76 Bhandarkar and Clark, cont. Factors favoring MIPS Operand specifier decoding Number of registers Separating floating point unit Simple jumps and branches (lower latency) Fancy VAX instructions: Unnecessary functionality Instruction scheduling Translation buffer Branch displacement size Arquitectura de Computadoras ISA- 76

77 Homework Assignment 3 Make a review of the ISA for a specific processor Write a three page report explaining the following: 1. Kind of IS Architecture (RISC, CISC or other, 16-bit, 32- bit, 64-bit) 2. Classes of instructions (ALU, Memory Movement, Branches, etc.) 3. Addressing Modes (immediate, base+displacemente, indirect, etc.) 4. Displacements in branches and control flow instructions (call, ret) 5. Special instructions: system calls, traps, access to special purpose registers 6. Instructions formats Arquitectura de Computadoras ISA- 77

78 Hw3: : List of Processors 1 Claudia Méndez Garza Xscale o ARM 2 José Alberto Ramírez Uresti Opteron AMD 64 bits 3 Víctor Echeverría Ríos Texas Instruments TMS320DM64x o un DSP Due date: September 26th, Arquitectura de Computadoras ISA- 78

79 Láminas complementarias no expuestas en la clase que pueden servir de soporte Arquitectura de Computadoras ISA- 79

80 VAX-11 Introduced by DEC in 1977: VAX- 11/780 Upward compatible from PDP bit word and addresses Virtual memory is first-class 16 GPRs (r15 is PC, r14 is SP), CCs Extremely orthogonal, memorymemory Decode as byte stream Opcode: operation, number of operands & operand type Variable-length address specifiers Arquitectura de Computadoras ISA- 80

81 VAX-11, cont. Data types 8-, 16-, 32-, 64-, 128-bit integers F (32 bits), D (64), G (64), H (128) FP Character string (8-bits/char) Decimal (4-bits/digit) Numeric string (8-bits/digit) Addresing modes include Literal (6 bits) 8-, 16-, 32-bit immediates Register, register deferred 8-, 16-, 32-bit displacements 8-, 16-, 32-bit displacement deferred Indexed Autoincrement Autodecrement Autoincrement deferred Arquitectura de Computadoras ISA- 81

82 VAX-11, cont. Operations Data Transfers (including string move) Arithmetic and Logical (2 and 3 operands) Control (Branch, Jump, etc. )» AOBLEQ (Add one and Branch if Less than or EQual) Procedure (CALLs save state) Bit Manipulation Floating Poing (Add/Sub/Mult/Divide) POLYF -- Polynomial Evaluation System (Exception, VM) Other» CRC -- Cycle redundant chech» INSQUE -- Insert entry in queue Arquitectura de Computadoras ISA- 82

83 VAX-11, cont. PC+0 PC+1 8 bits New instruction: opcode calls for three operands Specifier 1: four bits + register VAX has too many modes & formats PC+6 PC+9 + four byte displacements Specifier 2 + two byte displacements Specifier 3: index Specifier 3: indexed mode Serial semantics limit parallel execution PC+15 + four byte displacement next instruction The big deal with RISC is not REDUCED number of instructions; it s few modes & formats to facilitate pipelining Arquitectura de Computadoras ISA- 83

84 DEC Alpha Introduced by DEC in 1992 Ability to emulate VAX instructions important Strongly influenced by Cray-1 64-bit architecture Load/Store -- only displacement addressing Standard datatypes No byte loads/stores Registers bit GPRs (r31 = 0) bit FPRs VAX and IEEE floating point Arquitectura de Computadoras ISA- 84

85 DEC Alpha, cont. Four fixed-length instruction formats Sub-formats for computation instructions 32-bit instructions Designed with multiple-issue in mind No delayed branches Precise exceptions not automatic PAL code Arquitectura de Computadoras ISA- 85

86 DEC Alpha Instructions Formats Memory Format OpCode src/dest base displacement 0 PC-Relative Format OpCode src displacement 0 PAL-call Format OpCode PAL argument Arquitectura de Computadoras ISA- 86

87 DEC ALPHA Instruction Instruction Formats,, cont. Three-Register Integer Format OpCode src1 src function dest 0 Eight-bit Immediate Integer Format OpCode src1 const 1 function dest 0 Eight-bit Immediate Integer Format OpCode src1 src2 function dest 0 Arquitectura de Computadoras ISA- 87

88 DEC Alpha Instruction Set Operate Instructions Integer Arithmetic Logical (AND, OR, conditional MOV) Byte-manipulation Floating-point arithmetic Miscellaneous (memory prefetching, trap and memory barriers Load/Store Instructions Load/Store Quadwords (64-bits) Load-Linked/Store Conditional (for MP synchronization) Arquitectura de Computadoras ISA- 88

89 DEC Alpha Instruction Set,, cont. Control/Branching Instruction Branch on condition (8 conditions) in integer register Branch on condition (6 conditions) in FP register Unconditional branches Calculated jumps Branch Hints Different hint/rule type of branch Supervision Instructions PAL code for needed task Arquitectura de Computadoras ISA- 89

Reduced Instruction Set Computer (RISC)

Reduced Instruction Set Computer (RISC) Reduced Instruction Set Computer (RISC) Focuses on reducing the number and complexity of instructions of the ISA. RISC Goals RISC: Simplify ISA Simplify CPU Design Better CPU Performance Motivated by simplifying

More information

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek

Instruction Set Architecture. or How to talk to computers if you aren t in Star Trek Instruction Set Architecture or How to talk to computers if you aren t in Star Trek The Instruction Set Architecture Application Compiler Instr. Set Proc. Operating System I/O system Instruction Set Architecture

More information

Instruction Set Design

Instruction Set Design Instruction Set Design Instruction Set Architecture: to what purpose? ISA provides the level of abstraction between the software and the hardware One of the most important abstraction in CS It s narrow,

More information

Instruction Set Architecture (ISA) Design. Classification Categories

Instruction Set Architecture (ISA) Design. Classification Categories Instruction Set Architecture (ISA) Design Overview» Classify Instruction set architectures» Look at how applications use ISAs» Examine a modern RISC ISA (DLX)» Measurement of ISA usage in real computers

More information

Review: MIPS Addressing Modes/Instruction Formats

Review: MIPS Addressing Modes/Instruction Formats Review: Addressing Modes Addressing mode Example Meaning Register Add R4,R3 R4 R4+R3 Immediate Add R4,#3 R4 R4+3 Displacement Add R4,1(R1) R4 R4+Mem[1+R1] Register indirect Add R4,(R1) R4 R4+Mem[R1] Indexed

More information

Instruction Set Architecture

Instruction Set Architecture Instruction Set Architecture Consider x := y+z. (x, y, z are memory variables) 1-address instructions 2-address instructions LOAD y (r :=y) ADD y,z (y := y+z) ADD z (r:=r+z) MOVE x,y (x := y) STORE x (x:=r)

More information

Instruction Set Architecture (ISA)

Instruction Set Architecture (ISA) Instruction Set Architecture (ISA) * Instruction set architecture of a machine fills the semantic gap between the user and the machine. * ISA serves as the starting point for the design of a new machine

More information

CPU Organization and Assembly Language

CPU Organization and Assembly Language COS 140 Foundations of Computer Science School of Computing and Information Science University of Maine October 2, 2015 Outline 1 2 3 4 5 6 7 8 Homework and announcements Reading: Chapter 12 Homework:

More information

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University cwliu@twins.ee.nctu.edu.

Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University cwliu@twins.ee.nctu.edu. Computer Architecture Lecture 2: Instruction Set Principles (Appendix A) Chih Wei Liu 劉 志 尉 National Chiao Tung University cwliu@twins.ee.nctu.edu.tw Review Computers in mid 50 s Hardware was expensive

More information

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59

COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59 COMP 303 MIPS Processor Design Project 4: MIPS Processor Due Date: 11 December 2009 23:59 Overview: In the first projects for COMP 303, you will design and implement a subset of the MIPS32 architecture

More information

Introduction to MIPS Assembly Programming

Introduction to MIPS Assembly Programming 1 / 26 Introduction to MIPS Assembly Programming January 23 25, 2013 2 / 26 Outline Overview of assembly programming MARS tutorial MIPS assembly syntax Role of pseudocode Some simple instructions Integer

More information

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2

Advanced Computer Architecture-CS501. Computer Systems Design and Architecture 2.1, 2.2, 3.2 Lecture Handout Computer Architecture Lecture No. 2 Reading Material Vincent P. Heuring&Harry F. Jordan Chapter 2,Chapter3 Computer Systems Design and Architecture 2.1, 2.2, 3.2 Summary 1) A taxonomy of

More information

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX

Overview. CISC Developments. RISC Designs. CISC Designs. VAX: Addressing Modes. Digital VAX Overview CISC Developments Over Twenty Years Classic CISC design: Digital VAX VAXÕs RISC successor: PRISM/Alpha IntelÕs ubiquitous 80x86 architecture Ð 8086 through the Pentium Pro (P6) RJS 2/3/97 Philosophy

More information

Typy danych. Data types: Literals:

Typy danych. Data types: Literals: Lab 10 MIPS32 Typy danych Data types: Instructions are all 32 bits byte(8 bits), halfword (2 bytes), word (4 bytes) a character requires 1 byte of storage an integer requires 1 word (4 bytes) of storage

More information

Computer Organization and Architecture

Computer Organization and Architecture Computer Organization and Architecture Chapter 11 Instruction Sets: Addressing Modes and Formats Instruction Set Design One goal of instruction set design is to minimize instruction length Another goal

More information

SMIPS Processor Specification

SMIPS Processor Specification SMIPS Processor Specification 6.884 Spring 25 - Version: 25215 1 Introduction SMIPS is the version of the MIPS instruction set architecture (ISA) we ll be using for the processors we implement in 6.884.

More information

Intel 8086 architecture

Intel 8086 architecture Intel 8086 architecture Today we ll take a look at Intel s 8086, which is one of the oldest and yet most prevalent processor architectures around. We ll make many comparisons between the MIPS and 8086

More information

18-447 Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013

18-447 Computer Architecture Lecture 3: ISA Tradeoffs. Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013 18-447 Computer Architecture Lecture 3: ISA Tradeoffs Prof. Onur Mutlu Carnegie Mellon University Spring 2013, 1/18/2013 Reminder: Homeworks for Next Two Weeks Homework 0 Due next Wednesday (Jan 23), right

More information

MIPS Assembler and Simulator

MIPS Assembler and Simulator MIPS Assembler and Simulator Reference Manual Last Updated, December 1, 2005 Xavier Perséguers (ing. info. dipl. EPF) Swiss Federal Institude of Technology xavier.perseguers@a3.epfl.ch Preface MIPS Assembler

More information

CSE 141 Introduction to Computer Architecture Summer Session I, 2005. Lecture 1 Introduction. Pramod V. Argade June 27, 2005

CSE 141 Introduction to Computer Architecture Summer Session I, 2005. Lecture 1 Introduction. Pramod V. Argade June 27, 2005 CSE 141 Introduction to Computer Architecture Summer Session I, 2005 Lecture 1 Introduction Pramod V. Argade June 27, 2005 CSE141: Introduction to Computer Architecture Instructor: Pramod V. Argade (p2argade@cs.ucsd.edu)

More information

İSTANBUL AYDIN UNIVERSITY

İSTANBUL AYDIN UNIVERSITY İSTANBUL AYDIN UNIVERSITY FACULTY OF ENGİNEERİNG SOFTWARE ENGINEERING THE PROJECT OF THE INSTRUCTION SET COMPUTER ORGANIZATION GÖZDE ARAS B1205.090015 Instructor: Prof. Dr. HASAN HÜSEYİN BALIK DECEMBER

More information

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc

A single register, called the accumulator, stores the. operand before the operation, and stores the result. Add y # add y from memory to the acc Other architectures Example. Accumulator-based machines A single register, called the accumulator, stores the operand before the operation, and stores the result after the operation. Load x # into acc

More information

Computer Architectures

Computer Architectures Computer Architectures 2. Instruction Set Architectures 2015. február 12. Budapest Gábor Horváth associate professor BUTE Dept. of Networked Systems and Services ghorvath@hit.bme.hu 2 Instruction set architectures

More information

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches:

Solution: start more than one instruction in the same clock cycle CPI < 1 (or IPC > 1, Instructions per Cycle) Two approaches: Multiple-Issue Processors Pipelining can achieve CPI close to 1 Mechanisms for handling hazards Static or dynamic scheduling Static or dynamic branch handling Increase in transistor counts (Moore s Law):

More information

5 MIPS Assembly Language

5 MIPS Assembly Language 103 5 MIPS Assembly Language Today, digital computers are almost exclusively programmed using high-level programming languages (PLs), eg, C, C++, Java The CPU fetch execute cycle, however, is not prepared

More information

Pipeline Hazards. Structure hazard Data hazard. ComputerArchitecture_PipelineHazard1

Pipeline Hazards. Structure hazard Data hazard. ComputerArchitecture_PipelineHazard1 Pipeline Hazards Structure hazard Data hazard Pipeline hazard: the major hurdle A hazard is a condition that prevents an instruction in the pipe from executing its next scheduled pipe stage Taxonomy of

More information

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS

612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS 612 CHAPTER 11 PROCESSOR FAMILIES (Corrisponde al cap. 12 - Famiglie di processori) PROBLEMS 11.1 How is conditional execution of ARM instructions (see Part I of Chapter 3) related to predicated execution

More information

VLIW Processors. VLIW Processors

VLIW Processors. VLIW Processors 1 VLIW Processors VLIW ( very long instruction word ) processors instructions are scheduled by the compiler a fixed number of operations are formatted as one big instruction (called a bundle) usually LIW

More information

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9. Code Generation I Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings: 9.1-9.7 Stack Machines A simple evaluation model No variables

More information

Property of ISA vs. Uarch?

Property of ISA vs. Uarch? More ISA Property of ISA vs. Uarch? ADD instruction s opcode Number of general purpose registers Number of cycles to execute the MUL instruction Whether or not the machine employs pipelined instruction

More information

More on Pipelining and Pipelines in Real Machines CS 333 Fall 2006 Main Ideas Data Hazards RAW WAR WAW More pipeline stall reduction techniques Branch prediction» static» dynamic bimodal branch prediction

More information

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC

Chapter 2 Topics. 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC Chapter 2 Topics 2.1 Classification of Computers & Instructions 2.2 Classes of Instruction Sets 2.3 Informal Description of Simple RISC Computer, SRC See Appendix C for Assembly language information. 2.4

More information

More MIPS: Recursion. Computer Science 104 Lecture 9

More MIPS: Recursion. Computer Science 104 Lecture 9 More MIPS: Recursion Computer Science 104 Lecture 9 Admin Homework Homework 1: graded. 50% As, 27% Bs Homework 2: Due Wed Midterm 1 This Wed 1 page of notes 2 Last time What did we do last time? 3 Last

More information

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1

Divide: Paper & Pencil. Computer Architecture ALU Design : Division and Floating Point. Divide algorithm. DIVIDE HARDWARE Version 1 Divide: Paper & Pencil Computer Architecture ALU Design : Division and Floating Point 1001 Quotient Divisor 1000 1001010 Dividend 1000 10 101 1010 1000 10 (or Modulo result) See how big a number can be

More information

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com

Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com CSCI-UA.0201-003 Computer Systems Organization Lecture 7: Machine-Level Programming I: Basics Mohamed Zahran (aka Z) mzahran@cs.nyu.edu http://www.mzahran.com Some slides adapted (and slightly modified)

More information

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine

Exceptions in MIPS. know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine 7 Objectives After completing this lab you will: know the exception mechanism in MIPS be able to write a simple exception handler for a MIPS machine Introduction Branches and jumps provide ways to change

More information

LSN 2 Computer Processors

LSN 2 Computer Processors LSN 2 Computer Processors Department of Engineering Technology LSN 2 Computer Processors Microprocessors Design Instruction set Processor organization Processor performance Bandwidth Clock speed LSN 2

More information

Central Processing Unit (CPU)

Central Processing Unit (CPU) Central Processing Unit (CPU) CPU is the heart and brain It interprets and executes machine level instructions Controls data transfer from/to Main Memory (MM) and CPU Detects any errors In the following

More information

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I)

Lecture Outline. Stack machines The MIPS assembly language. Code Generation (I) Lecture Outline Code Generation (I) Stack machines The MIPS assembl language Adapted from Lectures b Profs. Ale Aiken and George Necula (UCB) A simple source language Stack- machine implementation of the

More information

Design of Pipelined MIPS Processor. Sept. 24 & 26, 1997

Design of Pipelined MIPS Processor. Sept. 24 & 26, 1997 Design of Pipelined MIPS Processor Sept. 24 & 26, 1997 Topics Instruction processing Principles of pipelining Inserting pipe registers Data Hazards Control Hazards Exceptions MIPS architecture subset R-type

More information

Assembly Language Programming

Assembly Language Programming Assembly Language Programming Assemblers were the first programs to assist in programming. The idea of the assembler is simple: represent each computer instruction with an acronym (group of letters). Eg:

More information

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals

How It All Works. Other M68000 Updates. Basic Control Signals. Basic Control Signals CPU Architectures Motorola 68000 Several CPU architectures exist currently: Motorola Intel AMD (Advanced Micro Devices) PowerPC Pick one to study; others will be variations on this. Arbitrary pick: Motorola

More information

EC 362 Problem Set #2

EC 362 Problem Set #2 EC 362 Problem Set #2 1) Using Single Precision IEEE 754, what is FF28 0000? 2) Suppose the fraction enhanced of a processor is 40% and the speedup of the enhancement was tenfold. What is the overall speedup?

More information

Computer organization

Computer organization Computer organization Computer design an application of digital logic design procedures Computer = processing unit + memory system Processing unit = control + datapath Control = finite state machine inputs

More information

Chapter 2 Logic Gates and Introduction to Computer Architecture

Chapter 2 Logic Gates and Introduction to Computer Architecture Chapter 2 Logic Gates and Introduction to Computer Architecture 2.1 Introduction The basic components of an Integrated Circuit (IC) is logic gates which made of transistors, in digital system there are

More information

INSTRUCTION LEVEL PARALLELISM PART VII: REORDER BUFFER

INSTRUCTION LEVEL PARALLELISM PART VII: REORDER BUFFER Course on: Advanced Computer Architectures INSTRUCTION LEVEL PARALLELISM PART VII: REORDER BUFFER Prof. Cristina Silvano Politecnico di Milano cristina.silvano@polimi.it Prof. Silvano, Politecnico di Milano

More information

Pipeline Hazards. Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. Based on the material prepared by Arvind and Krste Asanovic

Pipeline Hazards. Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. Based on the material prepared by Arvind and Krste Asanovic 1 Pipeline Hazards Computer Science and Artificial Intelligence Laboratory M.I.T. Based on the material prepared by and Krste Asanovic 6.823 L6-2 Technology Assumptions A small amount of very fast memory

More information

CPU Performance Equation

CPU Performance Equation CPU Performance Equation C T I T ime for task = C T I =Average # Cycles per instruction =Time per cycle =Instructions per task Pipelining e.g. 3-5 pipeline steps (ARM, SA, R3000) Attempt to get C down

More information

CS352H: Computer Systems Architecture

CS352H: Computer Systems Architecture CS352H: Computer Systems Architecture Topic 9: MIPS Pipeline - Hazards October 1, 2009 University of Texas at Austin CS352H - Computer Systems Architecture Fall 2009 Don Fussell Data Hazards in ALU Instructions

More information

Week 1 out-of-class notes, discussions and sample problems

Week 1 out-of-class notes, discussions and sample problems Week 1 out-of-class notes, discussions and sample problems Although we will primarily concentrate on RISC processors as found in some desktop/laptop computers, here we take a look at the varying types

More information

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE M A S S A C H U S E T T S I N S T I T U T E O F T E C H N O L O G Y DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE 1. Introduction 6.004 Computation Structures β Documentation This handout is

More information

THUMB Instruction Set

THUMB Instruction Set 5 THUMB Instruction Set This chapter describes the THUMB instruction set. Format Summary 5-2 Opcode Summary 5-3 5. Format : move shifted register 5-5 5.2 Format 2: add/subtract 5-7 5.3 Format 3: move/compare/add/subtract

More information

MICROPROCESSOR AND MICROCOMPUTER BASICS

MICROPROCESSOR AND MICROCOMPUTER BASICS Introduction MICROPROCESSOR AND MICROCOMPUTER BASICS At present there are many types and sizes of computers available. These computers are designed and constructed based on digital and Integrated Circuit

More information

Q. Consider a dynamic instruction execution (an execution trace, in other words) that consists of repeats of code in this pattern:

Q. Consider a dynamic instruction execution (an execution trace, in other words) that consists of repeats of code in this pattern: Pipelining HW Q. Can a MIPS SW instruction executing in a simple 5-stage pipelined implementation have a data dependency hazard of any type resulting in a nop bubble? If so, show an example; if not, prove

More information

Processor Architectures

Processor Architectures ECPE 170 Jeff Shafer University of the Pacific Processor Architectures 2 Schedule Exam 3 Tuesday, December 6 th Caches Virtual Memory Input / Output OperaKng Systems Compilers & Assemblers Processor Architecture

More information

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level

Computer System: User s View. Computer System Components: High Level View. Input. Output. Computer. Computer System: Motherboard Level System: User s View System Components: High Level View Input Output 1 System: Motherboard Level 2 Components: Interconnection I/O MEMORY 3 4 Organization Registers ALU CU 5 6 1 Input/Output I/O MEMORY

More information

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM

ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM ADVANCED PROCESSOR ARCHITECTURES AND MEMORY ORGANISATION Lesson-12: ARM 1 The ARM architecture processors popular in Mobile phone systems 2 ARM Features ARM has 32-bit architecture but supports 16 bit

More information

Introducción. Diseño de sistemas digitales.1

Introducción. Diseño de sistemas digitales.1 Introducción Adapted from: Mary Jane Irwin ( www.cse.psu.edu/~mji ) www.cse.psu.edu/~cg431 [Original from Computer Organization and Design, Patterson & Hennessy, 2005, UCB] Diseño de sistemas digitales.1

More information

MIPS Assembly Code Layout

MIPS Assembly Code Layout Learning MIPS & SPIM MIPS assembly is a low-level programming language The best way to learn any programming language is to write code We will get you started by going through a few example programs and

More information

Syscall 5. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas

Syscall 5. Erik Jonsson School of Engineering and Computer Science. The University of Texas at Dallas Syscall 5 System call 5 allows input of numerical data from the keyboard while a program is running. Syscall 5 is a bit unusual, in that it requires the use of register $v0 twice. In syscall 5 (as for

More information

EECS 427 RISC PROCESSOR

EECS 427 RISC PROCESSOR RISC PROCESSOR ISA FOR EECS 427 PROCESSOR ImmHi/ ImmLo/ OP Code Rdest OP Code Ext Rsrc Mnemonic Operands 15-12 11-8 7-4 3-0 Notes (* is Baseline) ADD Rsrc, Rdest 0000 Rdest 0101 Rsrc * ADDI Imm, Rdest

More information

MACHINE ARCHITECTURE & LANGUAGE

MACHINE ARCHITECTURE & LANGUAGE in the name of God the compassionate, the merciful notes on MACHINE ARCHITECTURE & LANGUAGE compiled by Jumong Chap. 9 Microprocessor Fundamentals A system designer should consider a microprocessor-based

More information

Intel 64 and IA-32 Architectures Software Developer s Manual

Intel 64 and IA-32 Architectures Software Developer s Manual Intel 64 and IA-32 Architectures Software Developer s Manual Volume 1: Basic Architecture NOTE: The Intel 64 and IA-32 Architectures Software Developer's Manual consists of seven volumes: Basic Architecture,

More information

PROBLEMS (Cap. 4 - Istruzioni macchina)

PROBLEMS (Cap. 4 - Istruzioni macchina) 98 CHAPTER 2 MACHINE INSTRUCTIONS AND PROGRAMS PROBLEMS (Cap. 4 - Istruzioni macchina) 2.1 Represent the decimal values 5, 2, 14, 10, 26, 19, 51, and 43, as signed, 7-bit numbers in the following binary

More information

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit.

Logical Operations. Control Unit. Contents. Arithmetic Operations. Objectives. The Central Processing Unit: Arithmetic / Logic Unit. Objectives The Central Processing Unit: What Goes on Inside the Computer Chapter 4 Identify the components of the central processing unit and how they work together and interact with memory Describe how

More information

In the Beginning... 1964 -- The first ISA appears on the IBM System 360 In the good old days

In the Beginning... 1964 -- The first ISA appears on the IBM System 360 In the good old days RISC vs CISC 66 In the Beginning... 1964 -- The first ISA appears on the IBM System 360 In the good old days Initially, the focus was on usability by humans. Lots of user-friendly instructions (remember

More information

WAR: Write After Read

WAR: Write After Read WAR: Write After Read write-after-read (WAR) = artificial (name) dependence add R1, R2, R3 sub R2, R4, R1 or R1, R6, R3 problem: add could use wrong value for R2 can t happen in vanilla pipeline (reads

More information

CHAPTER 7: The CPU and Memory

CHAPTER 7: The CPU and Memory CHAPTER 7: The CPU and Memory The Architecture of Computer Hardware, Systems Software & Networking: An Information Technology Approach 4th Edition, Irv Englander John Wiley and Sons 2010 PowerPoint slides

More information

An Overview of Stack Architecture and the PSC 1000 Microprocessor

An Overview of Stack Architecture and the PSC 1000 Microprocessor An Overview of Stack Architecture and the PSC 1000 Microprocessor Introduction A stack is an important data handling structure used in computing. Specifically, a stack is a dynamic set of elements in which

More information

MICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1

MICROPROCESSOR. Exclusive for IACE Students www.iace.co.in iacehyd.blogspot.in Ph: 9700077455/422 Page 1 MICROPROCESSOR A microprocessor incorporates the functions of a computer s central processing unit (CPU) on a single Integrated (IC), or at most a few integrated circuit. It is a multipurpose, programmable

More information

Lecture 8: Binary Multiplication & Division

Lecture 8: Binary Multiplication & Division Lecture 8: Binary Multiplication & Division Today s topics: Addition/Subtraction Multiplication Division Reminder: get started early on assignment 3 1 2 s Complement Signed Numbers two = 0 ten 0001 two

More information

IA-64 Application Developer s Architecture Guide

IA-64 Application Developer s Architecture Guide IA-64 Application Developer s Architecture Guide The IA-64 architecture was designed to overcome the performance limitations of today s architectures and provide maximum headroom for the future. To achieve

More information

High-speed image processing algorithms using MMX hardware

High-speed image processing algorithms using MMX hardware High-speed image processing algorithms using MMX hardware J. W. V. Miller and J. Wood The University of Michigan-Dearborn ABSTRACT Low-cost PC-based machine vision systems have become more common due to

More information

A SystemC Transaction Level Model for the MIPS R3000 Processor

A SystemC Transaction Level Model for the MIPS R3000 Processor SETIT 2007 4 th International Conference: Sciences of Electronic, Technologies of Information and Telecommunications March 25-29, 2007 TUNISIA A SystemC Transaction Level Model for the MIPS R3000 Processor

More information

Instruction Set Architecture

Instruction Set Architecture CS:APP Chapter 4 Computer Architecture Instruction Set Architecture Randal E. Bryant adapted by Jason Fritts http://csapp.cs.cmu.edu CS:APP2e Hardware Architecture - using Y86 ISA For learning aspects

More information

Administration. Instruction scheduling. Modern processors. Examples. Simplified architecture model. CS 412 Introduction to Compilers

Administration. Instruction scheduling. Modern processors. Examples. Simplified architecture model. CS 412 Introduction to Compilers CS 4 Introduction to Compilers ndrew Myers Cornell University dministration Prelim tomorrow evening No class Wednesday P due in days Optional reading: Muchnick 7 Lecture : Instruction scheduling pr 0 Modern

More information

Pentium vs. Power PC Computer Architecture and PCI Bus Interface

Pentium vs. Power PC Computer Architecture and PCI Bus Interface Pentium vs. Power PC Computer Architecture and PCI Bus Interface CSE 3322 1 Pentium vs. Power PC Computer Architecture and PCI Bus Interface Nowadays, there are two major types of microprocessors in the

More information

Chapter 7D The Java Virtual Machine

Chapter 7D The Java Virtual Machine This sub chapter discusses another architecture, that of the JVM (Java Virtual Machine). In general, a VM (Virtual Machine) is a hypothetical machine (implemented in either hardware or software) that directly

More information

Computer Organization and Components

Computer Organization and Components Computer Organization and Components IS5, fall 25 Lecture : Pipelined Processors ssociate Professor, KTH Royal Institute of Technology ssistant Research ngineer, University of California, Berkeley Slides

More information

Chapter 5 Instructor's Manual

Chapter 5 Instructor's Manual The Essentials of Computer Organization and Architecture Linda Null and Julia Lobur Jones and Bartlett Publishers, 2003 Chapter 5 Instructor's Manual Chapter Objectives Chapter 5, A Closer Look at Instruction

More information

Chapter 5, The Instruction Set Architecture Level

Chapter 5, The Instruction Set Architecture Level Chapter 5, The Instruction Set Architecture Level 5.1 Overview Of The ISA Level 5.2 Data Types 5.3 Instruction Formats 5.4 Addressing 5.5 Instruction Types 5.6 Flow Of Control 5.7 A Detailed Example: The

More information

1 Classical Universal Computer 3

1 Classical Universal Computer 3 Chapter 6: Machine Language and Assembler Christian Jacob 1 Classical Universal Computer 3 1.1 Von Neumann Architecture 3 1.2 CPU and RAM 5 1.3 Arithmetic Logical Unit (ALU) 6 1.4 Arithmetic Logical Unit

More information

X86-64 Architecture Guide

X86-64 Architecture Guide X86-64 Architecture Guide For the code-generation project, we shall expose you to a simplified version of the x86-64 platform. Example Consider the following Decaf program: class Program { int foo(int

More information

Microprocessor and Microcontroller Architecture

Microprocessor and Microcontroller Architecture Microprocessor and Microcontroller Architecture 1 Von Neumann Architecture Stored-Program Digital Computer Digital computation in ALU Programmable via set of standard instructions input memory output Internal

More information

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing.

a storage location directly on the CPU, used for temporary storage of small amounts of data during processing. CS143 Handout 18 Summer 2008 30 July, 2008 Processor Architectures Handout written by Maggie Johnson and revised by Julie Zelenski. Architecture Vocabulary Let s review a few relevant hardware definitions:

More information

EE282 Computer Architecture and Organization Midterm Exam February 13, 2001. (Total Time = 120 minutes, Total Points = 100)

EE282 Computer Architecture and Organization Midterm Exam February 13, 2001. (Total Time = 120 minutes, Total Points = 100) EE282 Computer Architecture and Organization Midterm Exam February 13, 2001 (Total Time = 120 minutes, Total Points = 100) Name: (please print) Wolfe - Solution In recognition of and in the spirit of the

More information

4 RISC versus CISC Architecture

4 RISC versus CISC Architecture 4 RISC versus CISC Architecture 4.1 INTRODUCTION Computer architectures, in general, have evolved toward progressively greater complexity, such as larger instruction sets, more addressing modes, more computational

More information

Computer Systems Architecture

Computer Systems Architecture Computer Systems Architecture http://cs.nott.ac.uk/ txa/g51csa/ Thorsten Altenkirch and Liyang Hu School of Computer Science University of Nottingham Lecture 10: MIPS Procedure Calling Convention and Recursion

More information

Instruction Sets. ECE 252 / CPS 220 Lecture Notes. 2006 by Lebeck Sorin, Roth, Hill, Wood, Sohi, Smith, Vijaykumar, Lipasti.

Instruction Sets. ECE 252 / CPS 220 Lecture Notes. 2006 by Lebeck Sorin, Roth, Hill, Wood, Sohi, Smith, Vijaykumar, Lipasti. what is an instruction set? what is a good instruction set? the forces that shape instruction sets aspects of instruction sets instruction set examples RISC vs. CISC 1 Readings Hennessy and Patterson chapter

More information

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 20: Stack Frames 7 March 08 CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 20: Stack Frames 7 March 08 CS 412/413 Spring 2008 Introduction to Compilers 1 Where We Are Source code if (b == 0) a = b; Low-level IR code

More information

8085 INSTRUCTION SET

8085 INSTRUCTION SET DATA TRANSFER INSTRUCTIONS Opcode Operand Description 8085 INSTRUCTION SET INSTRUCTION DETAILS Copy from source to destination OV Rd, Rs This instruction copies the contents of the source, Rs register

More information

MIPS IV Instruction Set. Revision 3.2 By Charles Price September, 1995

MIPS IV Instruction Set. Revision 3.2 By Charles Price September, 1995 MIPS IV Instruction Set Revision 3.2 By Charles Price September, 1995 Copyright 1995 MIPS Technologies, Inc. ALL RIGHTS RESERVED U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure

More information

Basic Computer Organization

Basic Computer Organization Chapter 2 Basic Computer Organization Objectives To provide a high-level view of computer organization To describe processor organization details To discuss memory organization and structure To introduce

More information

1 The Java Virtual Machine

1 The Java Virtual Machine 1 The Java Virtual Machine About the Spec Format This document describes the Java virtual machine and the instruction set. In this introduction, each component of the machine is briefly described. This

More information

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language

l C-Programming l A real computer language l Data Representation l Everything goes down to bits and bytes l Machine representation Language 198:211 Computer Architecture Topics: Processor Design Where are we now? C-Programming A real computer language Data Representation Everything goes down to bits and bytes Machine representation Language

More information

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored?

what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? Inside the CPU how does the CPU work? what operations can it perform? how does it perform them? on what kind of data? where are instructions and data stored? some short, boring programs to illustrate the

More information

CS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of

CS:APP Chapter 4 Computer Architecture. Wrap-Up. William J. Taffe Plymouth State University. using the slides of CS:APP Chapter 4 Computer Architecture Wrap-Up William J. Taffe Plymouth State University using the slides of Randal E. Bryant Carnegie Mellon University Overview Wrap-Up of PIPE Design Performance analysis

More information

Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm

Winter 2002 MID-SESSION TEST Friday, March 1 6:30 to 8:00pm University of Calgary Department of Electrical and Computer Engineering ENCM 369: Computer Organization Instructors: Dr. S. A. Norman (L01) and Dr. S. Yanushkevich (L02) Winter 2002 MID-SESSION TEST Friday,

More information

ARM Microprocessor and ARM-Based Microcontrollers

ARM Microprocessor and ARM-Based Microcontrollers ARM Microprocessor and ARM-Based Microcontrollers Nguatem William 24th May 2006 A Microcontroller-Based Embedded System Roadmap 1 Introduction ARM ARM Basics 2 ARM Extensions Thumb Jazelle NEON & DSP Enhancement

More information