CDA3101-F11-HW2-KEY

CDA3101-F11-HW2-KEY - 1 CDA3101 Organization of Computer...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CDA3101 Organization of Computer Systems Fall 2011 Homework #2 (40 points total) - KEY Assigned: Monday 12 September 2011 Due: at the start of lecture on Monday 26 September 2011 This assignment has three parts. Please start each part on a new page. Print NEATLY and put your name and section number on each page . Show your work. Please scan or Xerox-copy your homework before turning it in, and staple all pages together with a metal staple. Part I. Simple MIPS Statements and Programs 1. Short Answer (8 pts, 2 pt per item) Diagram and define (1-2 sentence) the following: 1.1. MIPS R-format instruction opcode rs rt rd shamt func where opcode = 6 bits, representation of operation to be performed rs, rt = 5 bits each, addresses of input registers rd = 5 bits, address of output register shamt = number of bits to shift operand func = specialization code for opcode representation 1.2. The field shamt (2 nd to last field) in MIPS R-format instruction number of bits to shift operand using logical or arithmetic shift instr. 1.3. What kind of operations does a MIPS I-format instruction represent? load/store, arithmetic with immediate (hardcoded) constant, branch inst. 1.4. Why does the following design rule hold in practice: s maller is faster ? smaller languages, algorithms, etc. require less hardware, which tends to incur shallower computational cascades (fewer gate delays) and therefore is faster 2. Short Explanation (8 pts, 2 pt per problem) What does each of the following MIPS statements do (say if it is valid MIPS programming syntax, or if it does anything)? 2.1. lw $t0, 44($s0) - access memory at base address in s0 register + 44 bytes - read word from memory at that location - transfer contents of word to register t0 2.2. addi $t1, $t1, 1 increment the contents of register $t1 by 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 2.3. slli $s2, $s3, 2 shift the contents of register $s3 left by 2 bits and store the result in register $s2 2.4. beq $s4, $s5, three if the contents of register s4 equal the contents of register s5, then jump to the label "three". Otherwise, continue on to the next statement Part II. MIPS Programming 3. Writing Simple MIPS Programs (16 pts total) 3.1. (6 pts: 2pt each) Write 3 MIPS code fragments that each multiply a number by eight using (i) shifting only, (ii) addition only, and (iii) multiplication by a constant Shifting: slli $s0, $s0, 3 #shift contents of s0 left 3 bits Addition: add $s0, $s1, $s1 #s0 <- s1 + s1 = 2*s1 add $s0, $s0, $s0 #s0 <- s0 + s0 = 2*s0 = 4*s1 add $s0, $s0, $s0 #s0 <- s0 + s0 = 2*s0 = 8*s1 Multiply: addi $t0, $0, 8 #put 8 into t0 mul $s0, $s0, t0 #s0 <- s0 * t0 = s0 * 8 3.2. (5 pts) Write a MIPS program that executes the following high-level code fragment (initialize x = 0; define registers and their contents; comment all code): for i = 1 to 21 by 4 do: { y := x + 5 * i ; x := 6 * y i } Let’s begin by diagramming the program execution (a few steps suffice): Iteration i x y (1 st stmt) x (2 nd stmt) 1 1 0 5 = 0 + 5 * 1
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/10/2011 for the course CDA 3101 taught by Professor Small during the Fall '08 term at University of Florida.

Page1 / 8

CDA3101-F11-HW2-KEY - 1 CDA3101 Organization of Computer...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online