Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1

Size: px
Start display at page:

Download "Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1"

Transcription

1 Part II Instruction-Set Architecture Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 1

2 MiniMIPS Instruction Formats op rs rt R 6 bits 5 bits 5 bits 5 bits I J Opcode Source register 1 Source register 2 rd Destination register sh 5 bits Shift amount op rs rt operand / offset fn 6 bits Opcode extension bits 5 bits 5 bits 16 bits Opcode op Source or base Destination or data 1 jump target address Imm ediate operand or address offset bits 26 bits Opcode Memory word address (byte address divided by 4) Figure 5.4 MiniMIPS instructions come in only three formats: register (R), immediate (I), and jump (J). Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 2

3 5.3 Simple Arithmetic/Logic Instructions Add and subtract already discussed; logical instructions are similar add $t,$s,$s1 # set $t to ($s)+($s1) sub $t,$s,$s1 $ $ # set $t to ($s)-($s1) and $t,$s,$s1 # set $t to ($s) ($s1) or $t,$s,$s1 # set $t to ($s) ($s1) xor $t,$s,$s1 $ $ # set $t to ($s) ($s1) nor $t,$s,$s1 # set $t to (($s) ($s1)) R op rs rt rd sh x ALU instruction Source Source Destination register 1 register 2 register fn Unused add = 32 sub = 34 Figure 5.5 The arithmetic instructions add and sub have a format that is common to all two-operand ALU instructions. For these, the fn field specifies the arithmetic/logic operation to be performed. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 3

4 Arithmetic/Logic with One Immediate Operand An operand in the range [ , ], or [x, xffff], can be specified in the immediate field. addi $t,$s,61 # set $t to ($s)+61 andi $t,$s,61 # set $t to ($s) 61 ori $t,$s,61 # set $t to ($s) 61 xori $t,$s,xff # set $t to ($s) xff For arithmetic instructions, the immediate operand is sign-extended op rs rt operand / offset I Errors 1 addi = 8 Source Destination Immediate operand Figure 5.6 Instructions such as addi allow us to perform an arithmetic or logic operation for which one operand is a small constant. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 4

5 5.4 Load and Store Instructions op rs rt operand / offset I 1 x lw = 35 Base Data Offset relative to base sw = 43 register register Memory A[] A[1] A[2]... A[i] lw $t,4($s3) lw $t,a($s3) Offset = 4i Address in base register Element i of array A Note on base and offset: The memory address is the sum of (rs) and an immediate value. Calling one of these the base and the other the offset is quite arbitrary. It would make perfect sense to interpret the address A($s3) as having the base A and the offset ($s3). However, a 16-bit base confines us to a small portion of memory space. Figure 5.7 MiniMIPS lw and sw instructions and their memory addressing convention that allows for simple access to array elements via a base address and an offset (offset = 4i leads us to the i th word). Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 5

6 lw, sw, and lui Instructions lw $t,4($s3) # load mem[4+($s3)] in $t sw $t,a($s3) # store ($t) in mem[a+($s3)] # ($s3) ( ) means content of $s3 lui $s,61 # The immediate value 61 is # loaded in upper half of $s # with lower 16b set to s I op rs rt operand / offset lui = 15 Unused Destination Immediate operand Content of $s after the instruction is executed Figure 5.8 The lui instruction allows us to load an arbitrary 16-bit value into the upper half of a register while setting its lower half to s. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 6

7 5.5 Jump and Branch Instructions Unconditional jump and jump through register instructions $ra is the symbolic name for reg. $31 (return j verify # go to mem loc named verify jr $ra # go to address that is in $ra; # $ra may hold a return address J op jump target address j = 2 address) x x x x From PC (incremented) op rs rt R Effective target address (32 bits) ALU instruction Source register Figure 5.9 The jump instruction j of MiniMIPS is a J-type instruction which is shown along with how its effective target address is obtained. The jump register (jr) instruction is R-type, with its specified register often being $ra. rd sh fn Unused Unused Unused jr = 8 Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 7

8 Memory Map in MiniMIPS Hex address 4 Reserved Program 1 M words Text segment 63 M words Addressable with 16-bit signed offset ffff Static data Dynamic data Data segment $28 $29 $3 $gp $fp $sp Stack 448 M words Stack segment 7ffffffc 8 Second half of address space reserved for memory-mapped I/O Figure 6.3 Overview of the memory address space in MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 8

9 Simple Datapath (from BP) Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 9

10 Conditional Branch Instructions Conditional branches use PC-relative addressing bltz $s1,l # branch on ($s1)< beq $s1,$s2,l # branch on ($s1)=($s2) bne $s1,$s2,l # branch on ($s1) ($s2) op rs rt operand / offset I bltz = 1 Source Zero eo Relative ea e branch ds distance in words ods op rs rt operand / offset I 1 x beq = 4 bne = 5 Source 1 Source 2 Relative branch distance in words Figure 5.1 (part 1) Conditional branch instructions of MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 1

11 Simple Datapath (from BP) Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 11

12 Comparison Instructions for Conditional Branching slt $s1,$s2,$s3 # if ($s2)<($s3), set $s1 to 1 # else set $s1 to ; # often followed by beq/bne slti $s1,$s2,61 # if ($s2)<61, set $s1 to 1 # else set $s1 to R op rs rt ALU instruction Source 1 register Source 2 register rd sh fn Destination Unused slt = 42 op rs rt operand / offset I slti = 1 Source Destination Immediate operand Figure 5.1 (part 2) Comparison instructions of MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 12

13 Examples for Conditional Branching If the branch target is too far to be reachable with a 16-bit offset (rare occurrence), the assembler automatically replaces the branch instruction beq $s,$s1,l1$s1 with: bne $s1,$s2,l2 # skip jump if (s1) (s2) j L1 # goto L1 if (s1)=(s2) L2:... Forming if-then constructs; e.g., if (i == j) x = x + y bne $s1,$s2,endif $s2 # branch on i j add $t1,$t1,$t2 # execute the then part endif:... If the condition were (i < j), we would change the first line to: slt $t,$s1,$s2 # set $t to 1 if i<j beq $t,$,endif # branch if ($t)=; # i.e., i not< j or i j Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 13

14 Compiling if-then-else Statements Example 5.3 Show a sequence of MiniMIPS instructions corresponding to: if (i<=j) x = x+1; z = 1; else y = y 1; z = 2*z Solution Similar to the if-then statement, but we need instructions for the else part and a way of skipping the else part after the then part. slt $t,$s2,$s1 # j<i? (inverse condition) bne $t,$zero,else # if j<i goto else part addi $t1,$t1,1 # begin then part: x = x+1 addi $t3,$zero,1 # z = 1 j endif # skip the else part else: addi $t2,$t2,-1 # begin else part: y = y 1 add $t3,$t3,$t3 # z = z+z endif:... Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 14

15 Loading and Storing Bytes Bytes can be used to store ASCII characters or small integers. MiniMIPS addresses refer to bytes, but registers hold words. lb $t,8($s3) # load rt with mem[8+($s3)] # sign-extend to fill reg lbu $t,8($s3) # load rt with mem[8+($s3)] # zero-extend to fill reg sb $t,a($s3) # LSB of rt to mem[a+($s3)] op rs rt immediate / offset I 1 x x lb = 32 lbu = 36 sb = 4 Base register Data register Address offset Figure 6.6 Load and store instructions for byte-size data elements. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 15

16 Logical Shifts MiniMIPS instructions for left and right shifting: sll $t,$s1,2 # $t=($s1) left-shifted by 2 srl $t,$s1,2 $ # $t=($s1) right-shifted hif by 2 sllv $t,$s1,$s # $t=($s1) left-shifted by ($s) srlv $t,$s1,$s # $t=($s1) right-shifted by ($s) R op rs rt x ALU Unused Source Destination Shift sll = instruction register register amount srl = 2 rd sh fn R op rs rt x ALU instruction Amount register Source register Figure 6.12 The four logical shift instructions of MiniMIPS. rd Destination register sh fn Unused sllv = 4 srlv = 6 Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 16

17 6.6 Additional Instructions MiniMIPS imips instructions ti for multiplication li and division: i i mult $s, $s1 # set Hi,Lo to ($s) ($s1) div $s, $s1 # set Hi to ($s)mod($s1) # and Lo to ($s)/($s1) mfhi $t # set $t to (Hi) mflo $t # set $t to (Lo) Reg file Mul/Div unit Hi Lo R op rs rt x ALU instruction Source register 1 Source register 2 rd sh fn Unused Unused mult = 24 div = 26 Figure 6.1 The multiply (mult) and divide (div) instructions of MiniMIPS. R op rs rt x ALU instruction Unused Unused rd Destination register sh fn Unused mfhi = 16 mflo = 18 Figure 6.11 MiniMIPS instructions for copying the contents of Hi and Lo registers into general registers. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 17

18 The 2 MiniMIPS Instructions from Chapter 6 (4 in all so far) Instruction Usage op Copy Move from Hi mfhi rd Move from Lo mflo rd Add unsigned addu rd,rs,rt Subtract unsigned subu rd,rs,rt Multiply mult rs,rt Arithmetic Multiply unsigned multu rs,rt Divide div rs,rt Divide unsigned divu rs,rt Table 6.2 (partial) Add immediate unsigned addiu rs,rt,imm op rs rt rd sh fn R 6 bits 5 bits 5 bits 5 bits 5 bits 6 bits Opcode Source register 1 Source register 2 Destination register Shift amount Opcode extension op rs rt operand / offset bits 5 bits 5 bits 16 bits I J Opcode Source or base Destination or data Immediate operand or address offset op jump target address bits 1 26 bits Opcode Memory word address (byte address divided by 4) Shift Add immediate unsigned addi s t imm Shift left logical sll rd,rt,sh Shift right logical srl rd,rt,sh Shift right arithmetic sra rd,rt,sh Shift left logical variable sllv rd,rt,rs Shift right logical variable srlv rt,rd,rs Shift right arith variable srav rd,rt,rd Load byte lb rt,imm(rs) Memory access 36 Control transfer 9 32 fn Load byte unsigned lbu rt,imm(rs) Store byte sb rt,imm(rs) 4 Jump and link jal L 3 System call syscall 12 Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 18

19 Table 6.2 The MiniMIPS Instructions Covered So Far Instruction Usage Instruction Usage Load upper immediate lui rt,imm Move from Hi mfhi rd Add add rd,rs,rt Move from Lo mflo rd Subtract sub rd,rs,rt Add unsigned addu rd,rs,rt Set less than slt rd,rs,rt, Subtract unsigned subu rd,rs,rt, Add immediate addi rt,rs,imm Multiply mult rs,rt Set less than immediate slti rd,rs,imm Multiply unsigned multu rs,rt AND and rd,rs,rt Divide div rs,rt OR or rd,rs,rtrs rt Divide unsigned divu rs,rtrt XOR xor rd,rs,rt Add immediate unsigned addiu rs,rt,imm NOR nor rd,rs,rt Shift left logical sll rd,rt,sh AND immediate andi rt,rs,imm Shift right logical srl rd,rt,sh OR immediate ori rt,rs,imm Shift right arithmetic ti sra rd,rt,sh XOR immediate xori rt,rs,imm Shift left logical variable sllv rd,rt,rs Load word lw rt,imm(rs) Shift right logical variable srlv rd,rt,rs Store word sw rt,imm(rs) Shift right arith variable srav rd,rt,rs Jump j L Load byte lb rt,imm(rs) Jump register jr rs Load byte unsigned lbu rt,imm(rs) Branch less than bltz rs,l Store byte sb rt,imm(rs) Branch equal beq rs,rt,l, Jump and link jal L Branch not equal bne rs,rt,l System call syscall Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 19

20 5.6 Addressing Modes Addressing Instruction Other elements involved Operand Implied Immediate Some place in the machine Extend, if required Register Reg spec Reg file Reg data Base Reg base Constant offset Reg file Reg data Add Me m addr Me mory Me m data PC-relative Incremented Constant offset PC Add Me m addr Me mory Me m data Pseudodirect PC Me m addr Me mory Me m data Figure 5.11 Schematic representation of addressing modes in MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 2

21 More Elaborate Addressing Modes Addressing Instruction Other elements involved Operand Indexed Update (with base) Reg f ile Index reg Base reg Increment amount Base reg Reg f ile Add Increment Me m addr Me m addr Me mory Me mory Me m data Me m data x := B[i] x := Mem[p] p := p + 1 Update (with indexed) Increment amount Reg f ile Base reg Index reg Increment Add Me m addr Me mory Me m data x := B[i] i := i + 1 Indirect PC Mem addr This part maybe replaced with any other form of address specification Me mory Me m addr, 2nd access Me m data Me mory Me m data, 2nd access t := Mem[p] x := Mem[t] x := Mem[Mem[p]] Figure 8.1 Schematic representation of more elaborate addressing modes not supported in MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 21

22 Usefulness of Some Elaborate Addressing Modes Update mode: XORing a string of bytes loop: lb $t,a($s) xor $s1,$s1,$t addi $s,$s,-1 bne $s,$zero,loop Indirect mode: Case statement case: lw $t,($s) # get s add $t,$t,$t # form 2s add $t,$t,$t # form 4s la $t1,t # base T add $t1,$t,$t1 lw $t2,($t1) # entry jr $t2 One instruction with update addressing Branch to location Li if s = i (switch var.) T T+4 T+8 T+12 T+16 T+2 L L1 L2 L3 L4 L5 Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 22

23 Example: Basic x86 Addressing Modes Two operands per instruction Source/dest operand Register Register Register Memory Memory Second source operand Register Immediate Memory Register Immediate Memory addressing modes Address in register Address = R base + displacement Address = R + scale base 2 R index (scale =, 1, 2, or 3) Address = R base + 2 scale R index + displacement ECE 15B Spring 211

24 6.1 Simple Procedure Calls Using a procedure involves the following sequence of actions: 1. Put arguments in places known to procedure (reg s $a-$a3) $ 2. Transfer control to procedure, saving the return address (jal) 3. Acquire storage space, if required, for use by the procedure 4. Perform the desired d task 5. Put results in places known to calling program (reg s $v-$v1) 6. Return control to calling point (jr) MiniMIPS instructions for procedure call and return from procedure: jal proc # jump to loc proc and link; # link means save the return # address (PC)+4 in $ra ($31) jr rs # go to loc addressed by rs Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 24

25 Illustrating a Procedure Call main PC jal proc Prepare to call Prepare to continue proc Save, etc. jr $ra Restore Figure 6.1 Relationship between the main program and a procedure. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 25

26 $ $1 $2 $3 $4 $5 $6 $7 $8 $9 $1 $11 $12 $13 $14 $15 $16 $17 $18 $19 $2 $21 $22 $23 $24 $25 $26 $27 $28 $29 $3 $31 $zero $at Reserved for assembler use $v Procedure results $v1 $a $a1 Procedure Saved $a2 arguments $a3 $t $t1 $t2 $t3 Temporary $t4 values $t5 $t6 $t7 $s $s1 $s2 Saved $s3 across Operands $s4 procedure $s5 calls $s6 $s7 $t8 More $t9 temporaries $k $k1 Reserved for OS (kernel) $gp Global pointer $sp Stack pointer Saved $fp Frame pointer $ra Return address A 4-byte word sits in consecutive memory addresses according to the big-endian order (most significant byte has the lowest address) Byte numbering: When loading a byte into a register, it goes in the low end Doublew ord Word Byte A doubleword sits in consecutive registers or memory locations according to the big-endian order (most significant word comes first) Recalling Register Conventions i t Figure 5.2 Registers and data sizes in MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 26

27 A Simple MiniMIPS Procedure Example 6.1 Procedure to find the absolute value of an integer. $v ($a) Solution The absolute value of x is x if x < and x otherwise. abs: sub $v,$zero,$a # put -($a) in $v; # in case ($a) < bltz $a,done # if ($a)< then done add $v,$a,$zero # else put ($a) in $v done: jr $ra # return to calling program In practice, we seldom use such short procedures because of the overhead that they entail. In this example, we have 3-4 instructions of overhead for 3 instructions of useful computation. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 27

28 Nested Procedure Calls main PC jal abc Prepare to call Prepare to continue abc Procedure abc Save xyz Procedure xyz jal xyz Text version is incorrect jr $ra Restore jr $ra Figure 6.2 Example of nested procedure calls. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 28

29 Fibonacci numbers F(n) = F(n-1)+F(n-2) F(1) = 1 F(2) = 1 n = F(n) = /* Recursive function in c */ int fib(int n) { If (n==1) return 1; If (n==2) return 1; return fib(n-1)+fib(n-2); } ECE 15B Spring 211

30 6.2 Using the Stack for Data Storage sp b a Analogy: Cafeteria stack of plates/trays Push c Pop x sp c b a sp = sp 4 mem[sp] = c sp b a x = mem[sp] sp = sp + 4 Figure 6.4 Effects of push and pop operations on a stack. push: addi $sp,$sp,-4 sw $t4,($sp) pop: lw $t5,($sp) addi $sp,$sp,4 Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 3

31 Memory Map in MiniMIPS Hex address 4 Reserved Program 1 M words Text segment 63 M words Addressable with 16-bit signed offset ffff Static data Dynamic data Data segment $28 $29 $3 $gp $fp $sp Stack 448 M words Stack segment 7ffffffc 8 Second half of address space reserved for memory-mapped I/O Figure 6.3 Overview of the memory address space in MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 31

32 6.3 Parameters and Results Stack allows us to pass/return an arbitrary number of values $sp $fp c b a. Frame for current procedure $sp Local variables Saved registers $fp z y. Old ($fp) c b a. Frame for current procedure Frame for previous procedure Before calling After calling Figure 6.5 Use of the stack by a procedure. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 32

33 Example of Using the Stack Saving $fp, $ra, and $s onto the stack and restoring them at the end of the procedure proc: sw $fp,-4($sp) # save the old frame pointer addi $fp,$sp, $sp # save ($sp) into $fp addi $sp,$sp, 12 # create 3 spaces on top of stack sw $ra,-8($fp) # save ($ra) in 2nd stack element sw $s,-12($fp) # save ($s) in top stack element $sp. ($s) ($ra). ($fp). $sp lw $s,-12($fp) # put top stack element in $s $fp lw $ra, -8($fp) # put 2nd stack element in $ra addi $sp,$fp, # restore $sp to original state $fp lw $fp,-4($sp) # restore $fp to original state jr $ra # return from procedure Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 33

34 Ch has 3 pools of memory Static storage: global variable storage, basically permanent, entire program run The Stack: local variable storage, parameters, return address (location of activation records in Java or stack frame in C) The Heap (dynamic malloc storage): data lives until deallocated by yprogrammer C requires knowing where objects are in memory, otherwise things don t work as expectedjava hides location of objects

35 Address space ~ FFFF FFFF hex A dd stack A program s address space contains 4 regions: stack: local variables, grows downward heap: space requested for pointers via malloc() ; resizes dynamically, grows upward static data: variables declared outside main, does not grow or shrink code: loaded when program starts, does not change ~ hex heap static data code For now, OS somehow prevents accesses between stack and heap (gray hash lines). Wait for virtual memory

36 Memory Map in MiniMIPS Hex address 4 Reserved Program 1 M words Text segment 63 M words Addressable with 16-bit signed offset ffff Static data Dynamic data Data segment $28 $29 $3 $gp $fp $sp Stack 448 M words Stack segment 7ffffffc 8 Second half of address space reserved for memory-mapped I/O Figure 6.3 Overview of the memory address space in MiniMIPS. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 36

37 Static variables If declared outside a procedure, allocated in static storage If declared inside procedure, allocated on the stack and freed when procedure returns. NB: main() is a procedure int myglobal; main() { int mytemp; }

38 The Heap (Dynamic memory) Large pool of memory, not allocated in contiguous order back-to-back requests for heap memory could result blocks very far apart where Java new command allocates memory In C, specify number of bytes of memory explicitly i l to allocate item int *ptr; ptr = (int *) malloc(sizeof(int)); /* malloc returns type (void *), so need to cast to right type */ malloc(): Allocates raw, uninitialized memory from heap

39 Memory Management How do we manage memory? Code, Static storage are easy: they never grow or shrink Stack space is also easy: stack frames are created and destroyed in last-in, first-out (LIFO) order Managing the heap is tricky: memory can be allocated / deallocated at any time

40 Heap Management Requirements Want malloc() and free() to run quickly. Want minimal memory overhead Want to avoid fragmentation* when most of our free memory is in many small chunks In this case, we might have many free bytes but not be able to satisfy a large request since the free bytes are not contiguous in memory. * This is technically called external fragmention

41 Heap Management An example Request R1 for 1 bytes Request R2 for 1 byte Memory from R1 is freed Request R3 for 5 bytes R2 (1 byte) R1 (1 bytes)

42 Heap Management An example Request R1 for 1 bytes Request R2 for 1 byte Memory from R1 is freed Request R3 for 5 bytes R2 (1 byte) R3? R3?

43 6.5 Arrays and Pointers Index: Use a register that holds the index i and increment the register in each step to effect moving from element i of the list to element i + 1 Pointer: Use a register that points to (holds the address of) the list element being examined and update it in each step to point to the next element Array index i Base Array A Pointer to A[i] Array A Add 1 to i; Compute 4i; Add 4i to base A[i] A[i + 1] Add 4 to get the address of A[i + 1] A[i] A[i + 1] Figure 6.8 Stepping through the elements of an array using the indexing ing method and the pointer updating method. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 43

44 Selection Sort Example 6.4 To sort a list of numbers, repeatedly perform the following: Find the max element, swap it with the last item, move up the last pointer A A A first first first max x y last last last y x Start of iteration Maximum identified End of iteration Figure 6.9 One iteration of selection sort. Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 44

45 Selection Sort Using the Procedure max Inputs to proc max In $a In $a1 Example 6.4 (continued) A A A first first first last Outputs from proc max max x y In $v In $v1 last y Start of iteration Maximum identified End of iteration last x sort: beq $a,$a1,done $ # single-element list is sorted jal max # call the max procedure lw $t,($a1) # load last element into $t sw $t,($v) # copy the last element to max loc sw $v1,($a1) # copy max value to last element addi $a1,$a1,-4 # decrement pointer to last element j sort # repeat sort for smaller list done:... # continue with rest of program Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 45

46 Finding the Maximum Value in a List of Integers Example 5.5 List A is stored in memory beginning at the address given in $s1. List length is given in $s2. Find the largest integer in the list and copy it into $t. Solution Scan the list, holding the largest element identified thus far in $t. lw $t,($s1) # initialize maximum to A[] addi $t1,$zero, # initialize index i to loop: add $t1,$t1,1 $ 1 1 # increment index i by 1 beq $t1,$s2,done # if all elements examined, quit add $t2,$t1,$t1 # compute 2i in $t2 add $t2,$t2,$t2 # compute 4i in $t2 add $t2,$t2,$s1 # form address of A[i] in $t2 lw $t3,($t2) # load value of A[i] into $t3 slt $t4,$t,$t3 # maximum < A[i]? beq $t4,$zero,loop # if not, repeat with no change addi $t,$t3, # if so, A[i] is the new maximum j loop # change completed; now repeat done:... # continuation of the program Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 46

Reduced Instruction Set Computer (RISC)

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 machine. Reduced number of cycles needed per instruction.

More information

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

Computer Architecture. The Language of the Machine

Computer Architecture. The Language of the Machine Computer Architecture The Language of the Machine Instruction Sets Basic ISA Classes, Addressing, Format Administrative Matters Operations, Branching, Calling conventions Break Organization All computers

More information

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support

MIPS ISA. 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support Components of an ISA EE 357 Unit 11 MIPS ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

MIPS Reference Guide

MIPS Reference Guide MIPS Reference Guide Free at PushingButtons.net 2 Table of Contents I. Data Registers 3 II. Instruction Register Formats 4 III. MIPS Instruction Set 5 IV. MIPS Instruction Set (Extended) 6 V. SPIM Programming

More information

ECE232: Hardware Organization and Design. Computer Organization - Previously covered

ECE232: Hardware Organization and Design. Computer Organization - Previously covered ECE232: Hardware Organization and Design Part 6: MIPS Instructions II http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Computer Organization

More information

MIPS Instruction Format

MIPS Instruction Format MIPS Instruction Format MIPS uses a 32-bit fixed-length instruction format. only three different instruction word formats: There are Register format Op-code Rs Rt Rd Function code 000000 sssss ttttt ddddd

More information

Computer Architecture. MIPS Instruction Set Architecture

Computer Architecture. MIPS Instruction Set Architecture Computer Architecture MIPS Instruction Set Architecture Instruction Set Architecture An Abstract Data Type Objects Registers & Memory Operations Instructions Goal of Instruction Set Architecture Design

More information

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013

ECE 2035 Programming HW/SW Systems Fall problems, 7 pages Exam Two 23 October 2013 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA

Mark Redekopp, All rights reserved. EE 357 Unit 11 MIPS ISA EE 357 Unit 11 MIPS ISA Components of an ISA 1. Data and Address Size 8-, 16-, 32-, 64-bit 2. Which instructions does the processor support SUBtract instruc. vs. NEGate + ADD instrucs. 3. Registers accessible

More information

Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1

Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1 Part II Instruction-Set Architecture Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 1 Short review of the previous lecture Performance = 1/(Execution time) = Clock rate / (Average CPI

More information

The MIPS Instruction Set Architecture

The MIPS Instruction Set Architecture The MIPS Set Architecture CPS 14 Lecture 5 Today s Lecture Admin HW #1 is due HW #2 assigned Outline Review A specific ISA, we ll use it throughout semester, very similar to the NiosII ISA (we will use

More information

ECE 15B Computer Organization Spring 2010

ECE 15B Computer Organization Spring 2010 ECE 15B Computer Organization Spring 2010 Dmitri Strukov Lecture 7: Procedures I Partially adapted from Computer Organization and Design, 4 th edition, Patterson and Hennessy, and classes taught by and

More information

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2)

Overview. Introduction to the MIPS ISA. MIPS ISA Overview. Overview (2) Introduction to the MIPS ISA Overview Remember that the machine only understands very basic instructions (machine instructions) It is the compiler s job to translate your high-level (e.g. C program) into

More information

MIPS Instruction Set

MIPS Instruction Set MIPS Instruction Set Prof. James L. Frankel Harvard University Version of 7:12 PM 3-Apr-2018 Copyright 2018, 2017, 2016, 201 James L. Frankel. All rights reserved. CPU Overview CPU is an acronym for Central

More information

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011

Recap from Last Time. CSE 2021: Computer Organization. Levels of Programming. The RISC Philosophy 5/19/2011 CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-3 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language

More information

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers

5/17/2012. Recap from Last Time. CSE 2021: Computer Organization. The RISC Philosophy. Levels of Programming. Stored Program Computers CSE 2021: Computer Organization Recap from Last Time load from disk High-Level Program Lecture-2 Code Translation-1 Registers, Arithmetic, logical, jump, and branch instructions MIPS to machine language

More information

Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1

Part II Instruction-Set Architecture. Jan Computer Architecture, Instruction-Set Architecture Slide 1 Part II Instruction-Set Architecture Jan. 211 Computer Architecture, Instruction-Set Architecture Slide 1 About This Presentation This presentation is intended to support the use of the textbook Computer

More information

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009

101 Assembly. ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 101 Assembly ENGR 3410 Computer Architecture Mark L. Chang Fall 2009 What is assembly? 79 Why are we learning assembly now? 80 Assembly Language Readings: Chapter 2 (2.1-2.6, 2.8, 2.9, 2.13, 2.15), Appendix

More information

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture

EEM 486: Computer Architecture. Lecture 2. MIPS Instruction Set Architecture EEM 486: Computer Architecture Lecture 2 MIPS Instruction Set Architecture EEM 486 Overview Instruction Representation Big idea: stored program consequences of stored program Instructions as numbers Instruction

More information

MIPS%Assembly% E155%

MIPS%Assembly% E155% MIPS%Assembly% E155% Outline MIPS Architecture ISA Instruction types Machine codes Procedure call Stack 2 The MIPS Register Set Name Register Number Usage $0 0 the constant value 0 $at 1 assembler temporary

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 8 December 2014 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Two 11 March Your Name (please print) total Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA CISC 662 Graduate Computer Architecture Lecture 4 - ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

Q1: /30 Q2: /25 Q3: /45. Total: /100

Q1: /30 Q2: /25 Q3: /45. Total: /100 ECE 2035(A) Programming for Hardware/Software Systems Fall 2013 Exam One September 19 th 2013 This is a closed book, closed note texam. Calculators are not permitted. Please work the exam in pencil and

More information

MIPS Instruction Reference

MIPS Instruction Reference Page 1 of 9 MIPS Instruction Reference This is a description of the MIPS instruction set, their meanings, syntax, semantics, and bit encodings. The syntax given for each instruction refers to the assembly

More information

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture

ECE468 Computer Organization & Architecture. MIPS Instruction Set Architecture ECE468 Computer Organization & Architecture MIPS Instruction Set Architecture ECE468 Lec4.1 MIPS R2000 / R3000 Registers 32-bit machine --> Programmable storage 2^32 x bytes 31 x 32-bit GPRs (R0 = 0) 32

More information

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly)

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam One 4 February Your Name (please print clearly) Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions

More information

CENG3420 Lecture 03 Review

CENG3420 Lecture 03 Review CENG3420 Lecture 03 Review Bei Yu byu@cse.cuhk.edu.hk 2017 Spring 1 / 38 CISC vs. RISC Complex Instruction Set Computer (CISC) Lots of instructions of variable size, very memory optimal, typically less

More information

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing

CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE. Debdeep Mukhopadhyay, CSE, IIT Kharagpur. Instructions and Addressing CS31001 COMPUTER ORGANIZATION AND ARCHITECTURE Debdeep Mukhopadhyay, CSE, IIT Kharagpur Instructions and Addressing 1 ISA vs. Microarchitecture An ISA or Instruction Set Architecture describes the aspects

More information

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions

MIPS R-format Instructions. Representing Instructions. Hexadecimal. R-format Example. MIPS I-format Example. MIPS I-format Instructions Representing Instructions Instructions are encoded in binary Called machine code MIPS instructions Encoded as 32-bit instruction words Small number of formats encoding operation code (opcode), register

More information

CSc 256 Midterm 2 Fall 2011

CSc 256 Midterm 2 Fall 2011 CSc 256 Midterm 2 Fall 2011 NAME: 1a) You are given a MIPS branch instruction: x: beq $12, $0, y The address of the label "y" is 0x400468. The memory location at "x" contains: address contents 0x40049c

More information

MACHINE LANGUAGE. To work with the machine, we need a translator.

MACHINE LANGUAGE. To work with the machine, we need a translator. LECTURE 2 Assembly MACHINE LANGUAGE As humans, communicating with a machine is a tedious task. We can t, for example, just say add this number and that number and store the result here. Computers have

More information

CSc 256 Midterm (green) Fall 2018

CSc 256 Midterm (green) Fall 2018 CSc 256 Midterm (green) Fall 2018 NAME: Problem 1 (5 points): Suppose we are tracing a C/C++ program using a debugger such as gdb. The code showing all function calls looks like this: main() { bat(5);

More information

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015

ECE 2035 A Programming Hw/Sw Systems Spring problems, 8 pages Final Exam 29 April 2015 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

M2 Instruction Set Architecture

M2 Instruction Set Architecture M2 Instruction Set Architecture Module Outline Addressing modes. Instruction classes. MIPS-I ISA. High level languages, Assembly languages and object code. Translating and starting a program. Subroutine

More information

SPIM Instruction Set

SPIM Instruction Set SPIM Instruction Set This document gives an overview of the more common instructions used in the SPIM simulator. Overview The SPIM simulator implements the full MIPS instruction set, as well as a large

More information

Mips Code Examples Peter Rounce

Mips Code Examples Peter Rounce Mips Code Examples Peter Rounce P.Rounce@cs.ucl.ac.uk Some C Examples Assignment : int j = 10 ; // space must be allocated to variable j Possibility 1: j is stored in a register, i.e. register $2 then

More information

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013

ECE 2035 Programming HW/SW Systems Spring problems, 6 pages Exam Three 10 April 2013 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 21 October 2016 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015

Branch Addressing. Jump Addressing. Target Addressing Example. The University of Adelaide, School of Computer Science 28 September 2015 Branch Addressing Branch instructions specify Opcode, two registers, target address Most branch targets are near branch Forward or backward op rs rt constant or address 6 bits 5 bits 5 bits 16 bits PC-relative

More information

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei

Computer Architecture Instruction Set Architecture part 2. Mehran Rezaei Computer Architecture Instruction Set Architecture part 2 Mehran Rezaei Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a MIPS Interpreter

More information

F. Appendix 6 MIPS Instruction Reference

F. Appendix 6 MIPS Instruction Reference F. Appendix 6 MIPS Instruction Reference Note: ALL immediate values should be sign extended. Exception: For logical operations immediate values should be zero extended. After extensions, you treat them

More information

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 9 December 2015

ECE 2035 A Programming Hw/Sw Systems Fall problems, 8 pages Final Exam 9 December 2015 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei

Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Instruction Set Architecture part 1 (Introduction) Mehran Rezaei Overview Last Lecture s Review Execution Cycle Levels of Computer Languages Stored Program Computer/Instruction Execution Cycle SPIM, a

More information

CS 61c: Great Ideas in Computer Architecture

CS 61c: Great Ideas in Computer Architecture MIPS Functions July 1, 2014 Review I RISC Design Principles Smaller is faster: 32 registers, fewer instructions Keep it simple: rigid syntax, fixed instruction length MIPS Registers: $s0-$s7,$t0-$t9, $0

More information

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016

ECE 2035 A Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 14 December 2016 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed.

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 22 September Your Name (please print clearly) Signed. Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions

More information

Flow of Control -- Conditional branch instructions

Flow of Control -- Conditional branch instructions Flow of Control -- Conditional branch instructions You can compare directly Equality or inequality of two registers One register with 0 (>,

More information

CMPE324 Computer Architecture Lecture 2

CMPE324 Computer Architecture Lecture 2 CMPE324 Computer Architecture Lecture 2.1 What is Computer Architecture? Software Hardware Application (Netscape) Operating System Compiler (Unix; Assembler Windows 9x) Processor Memory Datapath & Control

More information

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook)

Lecture 2. Instructions: Language of the Computer (Chapter 2 of the textbook) Lecture 2 Instructions: Language of the Computer (Chapter 2 of the textbook) Instructions: tell computers what to do Chapter 2 Instructions: Language of the Computer 2 Introduction Chapter 2.1 Chapter

More information

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont )

Chapter 2. Computer Abstractions and Technology. Lesson 4: MIPS (cont ) Chapter 2 Computer Abstractions and Technology Lesson 4: MIPS (cont ) Logical Operations Instructions for bitwise manipulation Operation C Java MIPS Shift left >>> srl Bitwise

More information

CSc 256 Midterm 2 Spring 2012

CSc 256 Midterm 2 Spring 2012 CSc 256 Midterm 2 Spring 2012 NAME: 1a) You are given this MIPS assembly language instruction (i.e., pseudo- instruction): ble $12, 0x20004880, there Translate this MIPS instruction to an efficient sequence

More information

CPS311 - COMPUTER ORGANIZATION. A bit of history

CPS311 - COMPUTER ORGANIZATION. A bit of history CPS311 - COMPUTER ORGANIZATION A Brief Introduction to the MIPS Architecture A bit of history The MIPS architecture grows out of an early 1980's research project at Stanford University. In 1984, MIPS computer

More information

Concocting an Instruction Set

Concocting an Instruction Set Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... Read: Chapter 2.1-2.7 L03 Instruction Set 1 A General-Purpose Computer The von

More information

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW

EE 109 Unit 13 MIPS Instruction Set. Instruction Set Architecture (ISA) Components of an ISA INSTRUCTION SET OVERVIEW 1 2 EE 109 Unit 13 MIPS Instruction Set Architecting a vocabulary for the HW INSTRUCTION SET OVERVIEW 3 4 Instruction Set Architecture (ISA) Defines the of the processor and memory system Instruction set

More information

Examples of branch instructions

Examples of branch instructions Examples of branch instructions Beq rs,rt,target #go to target if rs = rt Beqz rs, target #go to target if rs = 0 Bne rs,rt,target #go to target if rs!= rt Bltz rs, target #go to target if rs < 0 etc.

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed.

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam Two 23 October Your Name (please print clearly) Signed. Your Name (please print clearly) This exam will be conducted according to the Georgia Tech Honor Code. I pledge to neither give nor receive unauthorized assistance on this exam and to abide by all provisions

More information

MIPS Assembly Language

MIPS Assembly Language MIPS Assembly Language Chapter 15 S. Dandamudi Outline MIPS architecture Registers Addressing modes MIPS instruction set Instruction format Data transfer instructions Arithmetic instructions Logical/shift/rotate/compare

More information

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012

ECE 2035 Programming HW/SW Systems Fall problems, 6 pages Exam One 19 September 2012 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes

Chapter 2. Instructions: Language of the Computer. Adapted by Paulo Lopes Chapter 2 Instructions: Language of the Computer Adapted by Paulo Lopes Instruction Set The repertoire of instructions of a computer Different computers have different instruction sets But with many aspects

More information

Computer Architecture

Computer Architecture Computer Architecture Chapter 2 Instructions: Language of the Computer Fall 2005 Department of Computer Science Kent State University Assembly Language Encodes machine instructions using symbols and numbers

More information

MIPS Instruction Set Architecture (2)

MIPS Instruction Set Architecture (2) MIPS Instruction Set Architecture (2) Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu

More information

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck!

Question 0. Do not turn this page until you have received the signal to start. (Please fill out the identification section above) Good Luck! CSC B58 Winter 2017 Final Examination Duration 2 hours and 50 minutes Aids allowed: none Last Name: Student Number: UTORid: First Name: Question 0. [1 mark] Read and follow all instructions on this page,

More information

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University.

Rui Wang, Assistant professor Dept. of Information and Communication Tongji University. Instructions: ti Language of the Computer Rui Wang, Assistant professor Dept. of Information and Communication Tongji University it Email: ruiwang@tongji.edu.cn Computer Hierarchy Levels Language understood

More information

MIPS Assembly Language. Today s Lecture

MIPS Assembly Language. Today s Lecture MIPS Assembly Language Computer Science 104 Lecture 6 Homework #2 Midterm I Feb 22 (in class closed book) Outline Assembly Programming Reading Chapter 2, Appendix B Today s Lecture 2 Review: A Program

More information

Programming the processor

Programming the processor CSC258 Week 9 Logistics This week: Lab 7 is the last Logisim DE2 lab. Next week: Lab 8 will be assembly. For assembly labs you can work individually or in pairs. No matter how you do it, the important

More information

ECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013

ECE 2035 Programming Hw/Sw Systems Fall problems, 10 pages Final Exam 9 December 2013 Instructions: This is a closed book, closed note exam. Calculators are not permitted. If you have a question, raise your hand and I will come to you. Please work the exam in pencil and do not separate

More information

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats

Today s Lecture. MIPS Assembly Language. Review: What Must be Specified? Review: A Program. Review: MIPS Instruction Formats Today s Lecture Homework #2 Midterm I Feb 22 (in class closed book) MIPS Assembly Language Computer Science 14 Lecture 6 Outline Assembly Programming Reading Chapter 2, Appendix B 2 Review: A Program Review:

More information

EE 109 Unit 8 MIPS Instruction Set

EE 109 Unit 8 MIPS Instruction Set 1 EE 109 Unit 8 MIPS Instruction Set 2 Architecting a vocabulary for the HW INSTRUCTION SET OVERVIEW 3 Instruction Set Architecture (ISA) Defines the software interface of the processor and memory system

More information

ECE Exam I February 19 th, :00 pm 4:25pm

ECE Exam I February 19 th, :00 pm 4:25pm ECE 3056 Exam I February 19 th, 2015 3:00 pm 4:25pm 1. The exam is closed, notes, closed text, and no calculators. 2. The Georgia Tech Honor Code governs this examination. 3. There are 4 questions and

More information

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA

Mark Redekopp, All rights reserved. EE 352 Unit 3 MIPS ISA EE 352 Unit 3 MIPS ISA Instruction Set Architecture (ISA) Defines the software interface of the processor and memory system Instruction set is the vocabulary the HW can understand and the SW is composed

More information

Architecture II. Computer Systems Laboratory Sungkyunkwan University

Architecture II. Computer Systems Laboratory Sungkyunkwan University MIPS Instruction ti Set Architecture II Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Making Decisions (1) Conditional operations Branch to a

More information

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing

More information

Chapter 2. Instructions:

Chapter 2. Instructions: Chapter 2 1 Instructions: Language of the Machine More primitive than higher level languages e.g., no sophisticated control flow Very restrictive e.g., MIPS Arithmetic Instructions We ll be working with

More information

Assembly Programming

Assembly Programming Designing Computer Systems Assembly Programming 08:34:48 PM 23 August 2016 AP-1 Scott & Linda Wills Designing Computer Systems Assembly Programming In the early days of computers, assembly programming

More information

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN COMPUTER ORGANIZATION AND DESIGN 5 th The Hardware/Software Interface Edition Chapter 2 Instructions: Language of the Computer 2.1 Introduction Instruction Set The repertoire of instructions of a computer

More information

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College

Assembly Language Programming. CPSC 252 Computer Organization Ellen Walker, Hiram College Assembly Language Programming CPSC 252 Computer Organization Ellen Walker, Hiram College Instruction Set Design Complex and powerful enough to enable any computation Simplicity of equipment MIPS Microprocessor

More information

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary

Control Instructions. Computer Organization Architectures for Embedded Computing. Thursday, 26 September Summary Control Instructions Computer Organization Architectures for Embedded Computing Thursday, 26 September 2013 Many slides adapted from: Computer Organization and Design, Patterson & Hennessy 4th Edition,

More information

Control Instructions

Control Instructions Control Instructions Tuesday 22 September 15 Many slides adapted from: and Design, Patterson & Hennessy 5th Edition, 2014, MK and from Prof. Mary Jane Irwin, PSU Summary Previous Class Instruction Set

More information

Inequalities in MIPS (2/4) Inequalities in MIPS (1/4) Inequalities in MIPS (4/4) Inequalities in MIPS (3/4) UCB CS61C : Machine Structures

Inequalities in MIPS (2/4) Inequalities in MIPS (1/4) Inequalities in MIPS (4/4) Inequalities in MIPS (3/4) UCB CS61C : Machine Structures CS61C L8 Introduction to MIPS : Decisions II & Procedures I (1) Instructor Paul Pearce inst.eecs.berkeley.edu/~cs61c UCB CS61C : Machine Structures http://www.xkcd.org/627/ Lecture 8 Decisions & and Introduction

More information

CSc 256 Final Fall 2016

CSc 256 Final Fall 2016 CSc 256 Final Fall 2016 NAME: Problem 1 (25 points) Translate the C/C++ function func() into MIPS assembly language. The prototype is: void func(int arg0, int *arg1); arg0-arg1 are in $a0- $a1 respectively.

More information

We will study the MIPS assembly language as an exemplar of the concept.

We will study the MIPS assembly language as an exemplar of the concept. MIPS Assembly Language 1 We will study the MIPS assembly language as an exemplar of the concept. MIPS assembly instructions each consist of a single token specifying the command to be carried out, and

More information

Thomas Polzer Institut für Technische Informatik

Thomas Polzer Institut für Technische Informatik Thomas Polzer tpolzer@ecs.tuwien.ac.at Institut für Technische Informatik Branch to a labeled instruction if a condition is true Otherwise, continue sequentially beq rs, rt, L1 if (rs == rt) branch to

More information

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA.

Today s topics. MIPS operations and operands. MIPS arithmetic. CS/COE1541: Introduction to Computer Architecture. A Review of MIPS ISA. Today s topics CS/COE1541: Introduction to Computer Architecture MIPS operations and operands MIPS registers Memory view Instruction encoding A Review of MIPS ISA Sangyeun Cho Arithmetic operations Logic

More information

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design

ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design ENGN1640: Design of Computing Systems Topic 03: Instruction Set Architecture Design Professor Sherief Reda http://scale.engin.brown.edu School of Engineering Brown University Spring 2014 Sources: Computer

More information

Numbers: positional notation. CS61C Machine Structures. Faux Midterm Review Jaein Jeong Cheng Tien Ee. www-inst.eecs.berkeley.

Numbers: positional notation. CS61C Machine Structures. Faux Midterm Review Jaein Jeong Cheng Tien Ee. www-inst.eecs.berkeley. CS 61C Faux Midterm Review (1) CS61C Machine Structures Faux Midterm Review 2002-09-29 Jaein Jeong Cheng Tien Ee www-inst.eecs.berkeley.edu/~cs61c/ Numbers: positional notation Number Base B B symbols

More information

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction

A General-Purpose Computer The von Neumann Model. Concocting an Instruction Set. Meaning of an Instruction. Anatomy of an Instruction page 1 Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... A General-Purpose Computer The von Neumann Model Many architectural approaches

More information

Concocting an Instruction Set

Concocting an Instruction Set Concocting an Instruction Set Nerd Chef at work. move flour,bowl add milk,bowl add egg,bowl move bowl,mixer rotate mixer... Read: Chapter 2.1-2.6 L04 Instruction Set 1 A General-Purpose Computer The von

More information

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University Instructions: Language of the Computer Operations and Operands of the Computer Hardware Signed and Unsigned Numbers Representing

More information

MIPS Functions and the Runtime Stack

MIPS Functions and the Runtime Stack MIPS Functions and the Runtime Stack COE 301 Computer Organization Prof. Muhamed Mudawar College of Computer Sciences and Engineering King Fahd University of Petroleum and Minerals Presentation Outline

More information

Week 10: Assembly Programming

Week 10: Assembly Programming Week 10: Assembly Programming Arithmetic instructions Instruction Opcode/Function Syntax Operation add 100000 $d, $s, $t $d = $s + $t addu 100001 $d, $s, $t $d = $s + $t addi 001000 $t, $s, i $t = $s +

More information

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI.

CSCI 402: Computer Architectures. Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI. CSCI 402: Computer Architectures Instructions: Language of the Computer (3) Fengguang Song Department of Computer & Information Science IUPUI Recall Big endian, little endian Memory alignment Unsigned

More information

Assembly Language. Prof. Dr. Antônio Augusto Fröhlich. Sep 2006

Assembly Language. Prof. Dr. Antônio Augusto Fröhlich.   Sep 2006 Sep 2006 Prof. Antônio Augusto Fröhlich (http://www.lisha.ufsc.br) 33 Assembly Language Prof. Dr. Antônio Augusto Fröhlich guto@lisha.ufsc.br http://www.lisha.ufsc.br/~guto Sep 2006 Sep 2006 Prof. Antônio

More information

TSK3000A - Generic Instructions

TSK3000A - Generic Instructions TSK3000A - Generic Instructions Frozen Content Modified by Admin on Sep 13, 2017 Using the core set of assembly language instructions for the TSK3000A as building blocks, a number of generic instructions

More information

Midterm. Sticker winners: if you got >= 50 / 67

Midterm. Sticker winners: if you got >= 50 / 67 CSC258 Week 8 Midterm Class average: 4.2 / 67 (6%) Highest mark: 64.5 / 67 Tests will be return in office hours. Make sure your midterm mark is correct on MarkUs Solution posted on the course website.

More information

INSTRUCTION SET COMPARISONS

INSTRUCTION SET COMPARISONS INSTRUCTION SET COMPARISONS MIPS SPARC MOTOROLA REGISTERS: INTEGER 32 FIXED WINDOWS 32 FIXED FP SEPARATE SEPARATE SHARED BRANCHES: CONDITION CODES NO YES NO COMPARE & BR. YES NO YES A=B COMP. & BR. YES

More information

Announcements. EE108B Lecture MIPS Assembly Language III. MIPS Machine Instruction Review: Instruction Format Summary

Announcements. EE108B Lecture MIPS Assembly Language III. MIPS Machine Instruction Review: Instruction Format Summary Announcements EE108B Lecture MIPS Assembly Language III Christos Kozyrakis Stanford University http://eeclass.stanford.edu/ee108b PA1 available, due on Thursday 2/8 Work on you own (no groups) Homework

More information

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero

Do-While Example. In C++ In assembly language. do { z--; while (a == b); z = b; loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero Do-While Example In C++ do { z--; while (a == b); z = b; In assembly language loop: addi $s2, $s2, -1 beq $s0, $s1, loop or $s2, $s1, $zero 25 Comparisons Set on less than (slt) compares its source registers

More information