Practice Final 1 Solutions

EE 109L Review
Name: ___Solutions_______________________________
Closed Book /
Score: ________
1. Short Answer (16 pts.)
a. Storing temporary values in (memory / registers) is preferred due to the
(increased / decreased) access time.
b. Which of the following is NOT a special value that can be represented with the IEEE 754
representation?
i. Infinity
ii. Zero
iii. Not-a-Number
iv. None of the above
c. An integer (word) variable must start on an address that is a multiple of (1 / 2 / 4 / 8).
d. True / False: A circuit whose VOL value is 1 V can successfully communicate a logic '0' to a
circuit whose VIL is 0.5 V?
e. A family of circuits have IOH=-2 mA, IOL = 1mA, IIH = -0.2 mA and IIL = 0.25 mA. How
many other inputs can a single output be successfully wired to ensure operation in any
condition? When outputting logic '1' ten gates (2mA/0.2mA) can be connected but when
outputting logic '0' only 4 gates (1mA/0.25mA) can be connected. Thus 4 is the limit.
f. True / False: Assembler directives are executed by the MIPS processor just like instructions.
g. The address bus of a new computer is 38-bits wide, approximately how many bytes of
memory and I/O locations can the computer address? Show any work.
238 = 28*230 = 256 GB
2. Integer Operations (12 pts). Perform the following hexadecimal operations and state
whether OVerflow occurred. For subtraction, find the complement and add.
a.) C 5 A 0
- 6 8 B E
C 5 A 0
9 7 4 1
+
1
5 C E 2
b.)
signed ov: y /n
unsigned ov: y /n
F B 4 B
+ 9 F 3 5
9 A 8 0
signed ov: y /n
unsigned ov: y /n
3. Floating Point Representation (10 pts.) Convert the decimal number -139 to “shortened
IEEE FP format”. When you normalize show the G, R, and S bits. Then, use the “roundto-nearest” method, if needed.
139 = 10001011 <-- binary representation
= -1.000101 G=1,R=0,S=0*27
<-- normalized form
round up
= -1.000110*27
Final Results ---> 1
10110
000110
4. Assembler Directives (18 pts.): For the given the following assembler directives which
start placing data in memory at address 0x10001000, show the initialized contents of memory
(IN HEX) that will result from the directives. Fill UNUSED memory locations with 0’s!
Hint: For the “align” directive 0=byte, 1=half, 2=word,…
.data
CONST: .word
VALS:
0x12345678
.half 5,-1
.space 2
L1:
.byte
15,14,13
.align 2
DAT:
.word
(2 = word align)
0x21ABCD, 10
0 0 0 0 0 0 0 0
0x1000101c
0 0 0 0 0 0 0 0
0x10001018
0 0 0 0 0 0 0 a
0x10001014
0 0 2 1 a b c d
0x10001010
0 0 0 0 0 0 0 d
0x1000100c
0 e 0 f 0 0 0 0
0x10001008
f f f f 0 0 0 5
0x10001004
1 2 3 4 5 6 7 8
0x10001000
MIPS Assembly (40 pts.)
5. Examine each of the following instructions. Assume that each instruction is independent and
resets with the initial condition before the next instruction. For each instruction show the
entire 32-bit contents of each destination register. Work for the different operations can be
shown next to the instruction (this will allow me to assign partial credit).
$t0=
$t1=
$t2=
$t3=
$t4=
$t5=
$t6=
0000743C
00007448
000000B1
00000006
fffffff8
00000000
000080AC
Instruction
Result
$t5,10($t0)
$t5 = 0xffff95de
$t5,0xfffc($t1)
$t5 = 0x95de50f0
lbu
$t5,-2($t0)
$t5 = 0x000000ab
d) sub
$t5,$t2,$t3
$t5 = 0x000000ab
a)
lh
BCDE
9A78
EF05
95DE
2345
CDEF
89AB
b) lw
c)
e)
andi
$t5,$t3,0x7fff
$t5 = 0x00000006
f)
sll
$t5,$t2,3
$t5 = 0x00000588
g) sra
$t5,$t4,1
$t5 = 0xfffffffc
h) ori
$t5,$t4,$t3
$t5 = 0xfffffffe
i)
slt
$t5,$t2,$t4
$t5 = 0x00000000
j)
lb
$t5,0x13($t0)
$t5 = 0xffffff9a
F012
5630
C738
50F0
6789
0123
1234
M[0x7450]
M[0x744c]
M[0x7448]
M[0x7444]
M[0x7440]
M[0x743c]
M[0x7438]
Work
6. (25 pts.) Subroutines and Assembly
Examine the code sequence below. The starting address of certain instructions is shown in
the left-most column. Assume that initially $sp = 0x7fffeffc.
a. Show the stack contents and value of $sp just before execution of the first jr $ra
instruction and then again just before the second jr $ra execution.
b. Show the values of the indicated memory locations after the program terminates
c. Show the value of the indicated registers after the program terminates
Addr.
0x10010000
0x400000
0x400004
0x400008
0x400010
0x400014
0x40001c
0x400020
0x400024
0x40002c
0x400030
0x400034
0x400038
0x40003c
0x400040
0x400044
0x400048
0x40004c
0x400050
0x400054
0x400058
0x40005c
0x400060
0x400064
0x400068
0x40006c
0x400070
0x400074
0x400078
0x40007c
0x400080
.data
.word
0x01234567
.word
0xfedcba98
.space 4
.text
MAIN: la
$s2, X
la
$s3, Y
addi $sp,$sp,-8
sw
$s3,4($sp)
sw
$s2,0($sp)
jal
F1
addi $sp,$sp,8
sw
$v0,4($s3)
li
$v0,10
syscall
F2:
lw
$t7,0($sp)
addi $t7,$t7,1
sw
$t7,0($sp)
jr
$ra
F1:
addi $sp,$sp,-8
sw
$ra,4($sp)
lw
$t0,8($sp)
lw
$t1,12($sp)
lw
$t4,0($t0)
lw
$t5,0($t1)
sub $t6,$t5,$t4
sw
$t6,0($sp)
jal F2
sw
$t5,0($t0)
sw
$t4,0($t1)
lw
$v0,0($sp)
addi $sp,$sp,4
lw
$ra,0($sp)
addi $sp,$sp,4
jr
$ra
X:
Y:
RES:
a.) Stack before first
b.) Stack before second
jr $ra
jr $ra
0x7fffeffc
0x10010004 0x7fffeff8
0x10010004
0x10010000 0x7fffeff4
0x10010000
0x00400020 0x7fffeff0
0xfdb97532 0x7fffefec
0x7fffefe8
0x7fffefe4
0x7fffefe0
0x7fffefdc
0x7fffefd8
0x7fffefd4
0x7fffefec
$sp
0x7fffeff4
b.) Values in memory after
program terminates
0xfdb97532 0x10010008
0x01234567 0x10010004
0xfedcba98 0x10010000
c.) Values in memory after program terminates
0x10010000 $t0
0x10010004 $t1
0x01234567 $t4
0xfedcba98 $t5
0xfdb97531 $t6
0xfdb97532 $t7