





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The solutions to the first midterm exam for cs61c (computer architecture) at the university of california, berkeley, in fall 2010. It includes answers to multiple choice, true/false, and short answer questions covering various topics such as c structures, memory organization, arithmetic shifts, and floating-point representation.
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!
Your Name: _________Peter Perfect_____________ Your TA: Andrew Michael Conor Charles Login: cs61c-___ This exam is worth 85 points, or about 10% of your total course grade. The exam contains 7 questions. This booklet contains 9 numbered pages including the cover page. Put all answers on these pages, please; don't hand in stray pieces of paper. Question Points (Minutes) Score
Rubric: 2 pts / multiple choice, 1 pt / true/false. a) Suppose we have defined the C structure: struct player { int id; int numGoals; char name[8]; }; Also, we declare struct player players[3]; such that players starts at 0x10000000. What is the value of playerTwo after: struct player *playerTwo = players + 2; c) 0x b) Fill in the blank using one of the choices below. The quantity of numbers that single precision floating point can represent is ________ the quantity of numbers a 32-bit two’s complement integer can represent. b) less than c) True / False. Circle the right answer I) T The most expensive memory per bit is the smallest memory in a memory hierarchy. II) T The largest capacity memory is the slowest memory in a memory hierarchy. III) F For a given instruction set architecture and hardware implementation, a compiler that produces fewer instructions always produces a faster program. IV) F Data level parallelism is enabled by many small and independent tasks that can be spread among identical servers. V) T In map-reduce processing, the reduction step must wait until it has received data from all of the mapping steps before it can start.
“A box without hinges, key, or lid, yet golden treasure inside is hid.” J. R. R. Tolkien Rubric: 6 pts/ per part. a) Consider a 32-bit byte address machine with a direct mapped cache. The cache is organized with 4096 blocks of four 32-bit words, each block using write back cache policy. Draw and label the partitionings of the 32-bit memory address into the segments that are used to access the cache; Label each segment with its name and its width in bits. (shows bit numbers) 15 3 Rubric: 2 pts for tag, 2 pts for index, 2 pts for offset
31 0
“Twenty years of schoolin' / And they put you on the day shift.” Bob Dylan It was mentioned in lecture that computer designers had been fooled into thinking an arithmetic shift right (SRA) instruction is identical in effect to dividing by two. SRA performs identically to shift right logical (SRL) for positive two’s compliment numbers, but fills the leftmost bits with 1’s for negative numbers (most significant bit 1). Here is an example assuming an 8 bit word SRA by 3 on 0010 1001 => 0000 0101. SRA by 3 on 1010 1001 => 1111 0101. For one byte Two’s Complement integers, give an example that shows SRA cannot be used to implement the C signed integer division operator by powers of two. You only need to use 8-bit words in your example. 1111 1111 = - 1 SRA(1111 1111, 1) = - 1. Does not divide by 2. OR: Inconsistency in rounding schemes 0000 0101 = 5 SRA(0000 0101, 2) = 1. Rounds down. 1111 1011 = - 5 SRA(1111 1011,2) = - 2. Rounds up. Rubric: all or nothing; common mistakes: (1) to work the question using sign + magnitude numbers (the question explictly stated twos complement numbers) (2) to invent their own rounding scheme (the question explictly stated to use C semantics, which truncates -- rounds toward 0), and (3) to come up with a counter example in which shifting right actually worked, when the goal was to show an example where it didn’t. The quickest, easiest example was - 1 (1111 1111 in twos complement), shifted any number of places to the right always yields - 1, when it should round to 0).
“Mystery is at the heart of creativity. That, and surprise.” Julia Cameron What does the assembly function mystery return? Write your answer as a binary number. In one short phrase , describe how you got your answer. You may use some kind of obvious shorthand to denote long strings of ones or zeros, e.g. 16{1} to denote 16 ones in a row. Address Instruction 0x08001000 mystery: addiu $sp, $sp, - 4 0x08001004 sw $ra, 0($sp) 0x08001008 addiu $v0, $zero, 0 0x0800100c jal inner 0x08001010 lw $ra, 0($sp) 0x08001014 addiu $sp, $sp, 4 0x08001018 jr $ra 0x0800101c inner: lw $v0, 4($ra) 0x08001020 jr $ra
Binary encoding of addiu $sp, $sp, 4. Rubric: Full credit for correct binary number if we could tell it was produced by assembling addiu $sp, $sp, 4. Partial credit (non-exhaustive list):
“Garply: A metasyntactic variable like foo, once popular among SAIL hackers.” Computing Dictionary a) Examine the following MIPS function garply. Some of the instructions related to function calling conventions have been omitted. Fill in the instructions so that garply can be used correctly. Then assemble the 4 instructions that were given in the problem into binary MIPS machine code. Give your answers in binary, and then hexadecimal. Assume that the base address of the function garply is at 0x10000000. You may use some kind of obvious shorthand to denote long strings of ones or zeros, e.g. 16{1} to denote 16 ones in a row. See examples below. Machine Code MIPS assembly Binary Hexadecimal garply: addiu $sp,$sp,- 4 sw $ra, 0($sp) addiu $v0 $zero 0 lbu $t0 0($a0) beq $t0 $zero end addiu $a0 $a0 1 jal garply addiu $v0 $v0 1 end: lw $ra, 0($sp) addiu $sp,$sp, jr $ra
0x 0x 0x 0x 0x0c 0x Rubric: Six for the MIPS prologue/epilogue. Two points off for each major error (max of six points off). One point off for minor errors. Eight for the binary/hex. Each assembly into binary was worth 1.5 points; most errors resulted in losing these 1.5 points, but very minor ones could result in less being taken off. each translation into hex was worth .5 points, and you got these points if you correctly translated from binary, even if your binary was wrong. We rounded up the points lost to the next integer, so if you missed two binary and one hex, you were docked 4 points. Also, if you translated the addiu as addi because our mid-exam announcement confused you, we decided you should receive full credit.