





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
The fall 2010 cs61c midterm 1 exam questions covering various topics such as c structures, floating point numbers, cache organization, arithmetic shifts, and recursive functions.
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Your Name: ______________________________________________________________ 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
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; a) Indeterminate: uninitialized memory b) 0x c) 0x d) 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. a) greater than b) less than c) the same as c) True / False. Circle the right answer I) T / F The most expensive memory per bit is the smallest memory in a memory hierarchy. II) T / F The largest capacity memory is the slowest memory in a memory hierarchy. III) T / F For a given instruction set architecture and hardware implementation, a compiler that produces fewer instructions always produces a faster program. IV) T / F Data level parallelism is enabled by many small and independent tasks that can be spread among identical servers. V) T / F 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 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. (show bit numbers) b) Including all of the cache management bits, what is the total number of bits in the cache? Show your work, and to simplify the calculation, give your answer in kbits (1024 bits). 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 for powers of two. You only need to use 8-bit words in your example.
“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
“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 6 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. MIPS assembly Machine Code Binary Hexadecimal garply:
addiu $v0 $zero 0 lbu $t0 0($a0) beq $t0 $zero end addiu $a0 $a0 1 jal garply addiu $v0 $v0 1 end:
0x
0x b) Give a direct translation of garply into C. Don’t change how the function computes its answer (i.e., don’t change recursion into iteration, or vice-versa, or anything like that). Your solution shouldn’t take more than 3 lines of code, but we’ll give you up to six. Don’t forget to correctly fill in the argument and return types! _____ garply(_______________) {
_____________________________________________ } (Question cont’d on next page)