Bits
1. How many bits are needed to encode one ASCII character?
2. What ⃝ A.
⃝x B. ⃝x C. ⃝x D. ⃝ E.
⃝ A.
⃝ B.
⃝ C.
⃝x D. ⃝ E.
8bits 10bits 6bits 7 bits 9bits
CruzID: nobody @ucsc.edu CMPE 12 Final Exam – Version A
Winter 2019
is the size of a word in MIPS? Select all that apply. 8bytes
32 bits
8 nybbles 4 bytes 32bytes
Binary Arithmetic
3. Perform the following 12-bit two’s complement addition.
0b 0111 1100 0100 + 0b 0000 0001 1100
⃝ A. 000011011100 ⃝ B. 000001010100 ⃝ C. 011111100001 ⃝ D. 000010100111 ⃝x E. 011111100000
4. Which of these 8-bit two’s complement computations has carry out but no overflow? Select all that apply. ⃝ A. 0x1E + 0x26 = 0x44
⃝x B. 0xFA + 0xED = 0xE7
⃝ C. 0x0F + 0x85 = 0x94
⃝ D. 0x01 + 0x7F = 0x80 ⃝x E. 0xFF + 0x01 = 0x00
5. A logical right shift and an arithmetic right shift perform the same operation ⃝ A. True
⃝x B. False
CMPE 12 Final Exam – Version A Page 1 of 13 Winter 2019
7. What
⃝ A. 1235
8. What ⃝ A.
9. What
is the following 8-bit two’s complement number in signed magnitude form?
is the following base 9 number in base 5? 1069
⃝x B. 3225
⃝ C. 7425
⃝ D. 3055
⃝ E. 2225
⃝x B.
⃝ C.
⃝ D.
⃝ E.
is the range of values for an 8-bit two’s complement integer? 0to255
-128 to 127 -127 to 128 -128 to 128 -127 to 127
11010110
⃝ A. 10110110 ⃝x B. 10101010 ⃝ C. 01010110 ⃝ D. 00101010 ⃝ E. 11010110
10. Whatisthefollowingbase3numberinbase7?21013 ⃝ A. 7367
⃝ B. 1237 ⃝x C. 1217 ⃝ D. 647 ⃝ E. 467
11. 6-bittwo’scomplement,signedmagnitude,andunsignedallrepresentthesamenumberofintegers,somejust have more negative than positive.
⃝ A. True ⃝x B. False
CMPE 12 Final Exam – Version A Page 2 of 13 Winter 2019
CruzID: nobody @ucsc.edu
Data Representation
6. Which IEEE 754 single precision floating point number is furthest from zero? ⃝ A. 0xC70FFFFF
⃝x B. 0x47700000
⃝ C. 0x1F8FFFFF
⃝ D. 0x380FFFFF
⃝ E. 0xB8700000
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝x E.
Negative edge triggered D flip flop SR latch active high
Positive edge triggered D flip flop Dlatch
SR latch active low
14. Thisfigureislogicallyequivalenttowhichcircuit?
CruzID:
nobody
@ucsc.edu
Logic Design
12. Thisfigureislogicallyequivalenttowhichcircuit?
⃝ A.
⃝ B.
⃝x C.
⃝ D.
⃝ E.
XNORgate XORgate
AND gate XORgate Positive D-Latch
13. Whatdevicedoesthistimingdiagramrepresent?
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝x E.
ANDgate
XORgate
Negative D-Flip Flop XNORgate
OR gate
15. Thisfigureislogicallyequivalenttowhichcircuit?
⃝x A. ⃝x B.
⃝ C.
⃝ D.
⃝ E.
XOR gate
XOR gate Negative D-Latch Positive D-latch XNORgate
CMPE 12 Final Exam – Version A
Page 3 of 13
Winter 2019
CruzID: nobody @ucsc.edu 16. SelecttheBooleanexpressionmatchingthefilledareasofthisVenndiagram.
⃝ A.
⃝ B.
⃝ C.
⃝ D.
⃝x E.
(Red + Square) · (Big · Red · Square) · (Big + Red + Square) Red·Square·(Big·Red·Square)·(Big+Red+Square) (Red + Square) + (Big · Red · Square) · (Big + Red + Square) Red · Square · (Big · Red · Square) Red·Square·(Big·Red·Square)+(Big+Red+Square)
17. Howmanyoutputsdoesa4-16decoderhave? ⃝ A. 64
⃝ B. 4 ⃝ C. 1 ⃝x D. 16 ⃝ E. 32
Memory
18. How many bits are needed to represent a memory location address in a 4TB memory space that is 64-byte addressable?
⃝ A. 28 ⃝x B. 36 ⃝ C. 64 ⃝ D. 34 ⃝ E. 234
19. Howmuchmemoryisallocatedwiththefollowinglineofcode?
.asciiz “ce_12”
⃝x A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
6 bytes 5words 4bytes 2words 5bytes
CMPE 12 Final Exam – Version A
Page 4 of 13
Winter 2019
CruzID: nobody @ucsc.edu For the following two questions, assume a portion of data memory looks like this:
ADDRESS CONTENTS
0x10011085 0xCD
0x10011084 0xAB
0x10011083 0x87
0x10011082 0x65
0x10011081 0x43
0x10011080 0x21
20. Assumingbigendianmemorystorage,whatisin$t7afterthefollowinginstructions?
ADDI $t0, $zero, 0x10011080
LH $t7, 2($t0)
SW $t7, ($t0)
LW $t7, ($t0)
⃝ A. 0x87654321 ⃝ B. 0x00008765 ⃝x C. 0x00006587 ⃝ D. 0xFFFF8765 ⃝ E. 0x00004321
21. Assuminglittleendianmemorystorage,whatisin$t0afterthefollowinginstructions?
LI $t3, 0x10011082
LW $t0, ($t3)
⃝ A.
⃝ B.
⃝ C.
⃝x D. ⃝ E.
ASCII
0x00008765
0x5678BADC
0x6587ABCD
Undefined. There will be an alignment error. 0xCDAB8765
22. DecodethefollowingASCIIstring.Valuesaregiveninhex.
44 69 64 20 79 6f 75 20 65 76 65 72 20 68 65 61 72 20 74 68 65 20 74 72 61 67 65 64 79 20 6f 66 20 44 61 72 74 68 20 50 6c 61 67 75 65 69 73 20 74 68 65 20 57 69 73 65 3f
⃝x A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
Did you ever hear the tragedy of Darth Plagueis the Wise? No! Try not. Do. Or do not. There is no try.
Help me, Obi-Wan Kenobi. You’re my only hope.
I have a bad feeling about this.
I find your lack of faith disturbing.
23. SaythatauserentersasingleASCIIcharacterintherange‘0’-‘9’.Assumethattheuserinputisstoredin$v0. Which MIPS instruction would you use to convert their input into an integer in the range 0-9?
⃝ A. subi $t0, $v0, 49 ⃝x B. subi $t0, $v0, 48 ⃝ C. addi $t0, $v0, 48 ⃝ D. subi $t0, $v0, 30 ⃝ E. subi $t0, $v0, 60
CMPE 12 Final Exam – Version A
Page 5 of 13
Winter 2019
⃝ A.
ADDIU $1 $0 0xABCD
SRL $1 $1 16
OR $16 $13 $1
⃝B. ORI ⃝C. LI
$16 $13 0xABCDEF00
$1 0xABCDEF00
OR $16 $13 $1
⃝ D. LUI
OR $16 $13 $1
⃝ A. ⃝x B.
⃝ C.
⃝ D.
⃝ E.
$t0-$t9 $s0 – $s7 $sp $v0-$v1 $a0-$a3
$1 0xEF00
ORI $16 $16 0xABCD
⃝x E. LUI
ORI $1 $1 0xEF00
OR $16 $13 $1
26. Whichregister(s)inMIPSmustthecalleepreserve?
CMPE 12 Final Exam – Version A
Page 6 of 13
Winter 2019
$1 0xABCD
CruzID: nobody @ucsc.edu
MIPS
24. Whatisthevalueof$t0afterthefollowinginstructionsareexecuted(representedinhex)?
li $t1, 5
li $t0, 5
loop:
sll $t0, $t0, 1
addi $t1, $t1, -1
bgez $t1, loop
li $v0, 10
syscall
⃝x A. 0x00000140 ⃝ B. 0x0001FA00 ⃝ C. 0x000000A0 ⃝ D. 0x00001400 ⃝ E. 0x001000FA
25. WhichMIPS32native/basicinstruction(s)performthesamefunctionasthefollowingpseudoinstruction?
ORI $s0 $t5 0xABCDEF00
CruzID:
27. Whatisthevalueof$t0afterthefollowinginstructionsareexecuted?
li $t0, 4
li $t1, 5
add $t0, $t1, $t0
addi $t0, $t0, -1
xor $t0, $t0, $t0
nobody
@ucsc.edu
⃝x A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
0
6
10
8
Not enough information given
28. Whatistheleastsignificantbytestoredin$t0afterthefollowingMIPScommandsexecute?
li $t0, 0x9F
andi $t0, $t0, 0x0F
⃝x A. 00001111 ⃝ B. 10011111 ⃝ C. 11110000 ⃝ D. 00011111 ⃝ E. 00000000
29. WhatisprintedtothescreenafterthefollowingMIPScommandsexecute?
1 2 3 4 5 6 7 8 9
.data
prompt1: .ascii “I”
prompt2: .asciiz ” LOVE”
prompt3: .asciiz ” CE 12 FINAL”
.text
li $v0, 4
la $a0, prompt1
syscall
⃝ A.
⃝ B. ⃝x C. ⃝ D. ⃝ E.
I
LOVE
I
I LOVE
I LOVE CE12 FINAL nothing
CMPE 12 Final Exam – Version A
Page 7 of 13
Winter 2019
30. Processinganinstructionrequiresthefollowingsteps
a. Execute operation/evaluate effective address b. Write value to register file
c. Fetch instruction from memory
d. Access data from memory
e. Decode instruction
What is the correct ordering for these steps? ⃝ A. ecadb
⃝x B. ceadb
⃝ C. caedb
⃝ D. deacb ⃝ E. aebdc
31. WhichcombinationofMIPSinstructionsperformapopoperationofonewordfromthestack?
⃝ A.
⃝ B.
⃝x C.
sw $t0, ($sp)
subi $sp, $sp, 4
addi $sp, $sp, 4
lw $t0, ($sp)
lw $t0, ($sp)
addi $sp, $sp, 4
⃝ D. subi $sp, $sp, 4 sw $t0, ($sp)
⃝ E.
The next four questions will refer to the following MIPS code:
1 .text
2 la $a0, str1
3 addiu $v0, $zero, 4
4 syscall
5
6 la $a0, str2
7 syscall
8
9 lbu $a0, str3
10 addiu $v0, $zero, 11
11 syscall
12
13 addiu $v0, $zero, 1
14 syscall
15
16 addiu $v0, $zero, 10
17 syscall
18
19 .data
20 str1: .ascii “hello”
21 str2: .asciiz “there”
22 str3: .byte 0x21 0x21 0x00
none of the above
CMPE 12 Final Exam – Version A
Page 8 of 13
Winter 2019
CruzID:
nobody
@ucsc.edu
32. Assumeyouchangedline21intheoriginalprogramfrom
str2: .asciiz “there”
to
str2: .ascii “there”
What will be printed to the screen after the altered program completes execution? ⃝ A. hellothere!!33
⃝ B. hellotherethere!33
⃝ C. hellothere!33
⃝x D. hellothere!!there!!!33 ⃝ E. hellothere!!there!!33
33. Whatwillbeprintedtothescreenaftertheoriginalprogramcompletesexecution? ⃝x A. hellotherethere!33
⃝ B. hellothere!!33
⃝ C. hellotherethere!!33 ⃝ D. hellothere!33
⃝ E. hellotherethere!21
34. Assumeyouchangedline13intheoriginalprogramfrom
addiu $v0, $zero, 1
to
addiu $v0, $zero, 35
What will be printed to the screen after the altered program completes execution? ⃝x A. hellotherethere!00000000000000000000000000100001
⃝ B. hellothere!00000000000000000000000000100001
⃝ C. hellothere!!00000000000000000000000000100001
⃝ D. hellotherethere!0x00000021 ⃝ E. hellotherethere!33
35. Giventhebranchinstructioninmachinecode
000101 00010 01000 1111111111111100
Assume the branch target address is 0x2004, what is the address of the branch instruction?
⃝ A.
⃝ B.
⃝x C.
⃝ D.
⃝ E.
None of the other answers
0x2004
0x2010
0x2018
0x2014
CMPE 12 Final Exam – Version A
Page 9 of 13
Winter 2019
CruzID: nobody
@ucsc.edu
CruzID: nobody @ucsc.edu
The addresses of some of the instructions of the following program are listed. Please refer to the program for the
next two questions
.text
main:
0x00400000 jal getString
move $a0, $v0
li $v0, 4
0x0040000c syscall
li $v0, 10
syscall
0x00400018 getString:
#sets v0 to address of string
la
0x00400020 jr
.data
string1: .asciiz
$v0, string1
$ra
“Greetings!”
36. Whatisthevalueof$pcrightafterthejalistaken? ⃝ A. 0x0040000c
⃝ B. 0x00400000 ⃝x C. 0x00400018 ⃝ D. 0x00400020 ⃝ E. 0x00400004
37. Whatisthevalueof$rarightafterthejalistaken? ⃝ A. 0x0040000c
⃝ B. 0x00400000 ⃝ C. 0x00400020 ⃝ D. 0x00400018 ⃝x E. 0x00400004
CMPE 12 Final Exam – Version A
Page 10 of 13
Winter 2019
⃝ A.
⃝ B.
⃝x C.
⃝ D.
⃝ E.
9753
’%#!
97531
0x39 0x37 0x35 0x33 0x31 97531/
Instruction Decoding
39. AssumeanISAwith8generalpurposeregistersandthefollowing16-bitinstructionformat:
| opcode | RD | RS | RT |
How many unique instructions can this ISA have? ⃝ A. 16
⃝ B. 9
⃝ C. 7
⃝x D. 128 ⃝ E. 8
40. DecodethefollowingMIPS32instruction:0x8D4C3210
⃝ A. SW ⃝ B. AND ⃝ C. ANDI ⃝x D. LW ⃝ E. LW
$t2 0x0101 ($t3)
$t2 0x0123 $t4
$t2 $t4 0x0123
$t4 0x3210 ($t2)
$t2 0x3210 ($t4)
CMPE 12 Final Exam – Version A
Page 11 of 13
Winter 2019
CruzID: nobody @ucsc.edu
Arrays
38. ThenextquestionreferstothefollowingMIPScode.Assumeallmemorylocationsareinitializedto0x0000.
.text
la $t0, space
li $t1, 0
li $t2, 0x39
loop:
sb $t2, ($t0)
addi $t0, $t0, 1 # increment address
addi $t1, $t1, 1 # incrememt counter
subi $t2, $t2, 2
blt $t1, 5, loop
la $a0, space
li $v0, 4
syscall
li $v0, 10
syscall
.data
space: .space 10
What will be printed to the screen after the program completes execution?
CruzID: nobody @ucsc.edu
41. DecodethefollowingMIPS32instruction:0x01097820.Selectallthatapply. ⃝ A. ADD $t0 $t1 $t7
⃝B. AND$8 $9 $15
⃝C. ADD$8 $9 $15
⃝x D. ADD $t7 $t0 $t1 ⃝x E. ADD $15 $8 $9
Data Path
42. Assume $t0 = 5 and LB $t0 4($t0) is executed. The programmer has access to all memory locations. What is the value on wire 9?
⃝ A.
⃝ B.
⃝ C.
⃝x D. ⃝ E.
5
9
Not enough information given 4
8
CMPE 12 Final Exam – Version A
Page 12 of 13
Winter 2019
CruzID: nobody @ucsc.edu 43. TheinstructionSUBI $t7 $t7 -1isexecuted.Whatisthevalueonwire4?
⃝ A. ⃝x B.
⃝ C.
⃝ D.
⃝ E.
None of the other answers 0xFFFF
0xF
0xFFFFFFFF
Not enough information given
44. Assume the values on wires 5, 7, 10, 11, and 12 are 0x08, 0x12, 0x1A, 0x1B and 0x1B respectively. Which instruction could correspond to these values?
⃝ A.
⃝ B.
⃝ C.
⃝ D. LW $t0 12($t1)
⃝x A.
⃝ B.
⃝ C.
⃝ D.
⃝ E.
0xF4
0x08
Not enough information given 0x10
0xAB
Not enough information given
ADDI $12 $8 18
ADDI $s1 $s2 8
⃝x E.
45. Assume$s0=0xAB,$s1=0xF4andSW $s1 8($s0)isexecuted.Whatisthevalueonwire8?
LH $t8 8($t9)
CMPE 12 Final Exam – Version A
Page 13 of 13
Winter 2019