Last name _Points__________ First name
_Max_________9/9_
Section _A[A|B]_____
CSE378 Autumn 2003
Miniquiz #4
Thu 10/16/2003
1 pt. per part except as noted
No calculators!
A. Mark each one A for architecture (part of the hardware specification
of the machine) or C for convention (generally or even always observed
by software but not required by architecture).
- Number of general-purpose registers A
- Location of the first word of the .data segment C
- Fact that $0 always has the value 0 A
- Fact that $29 points to the top of the stack C
- Fact that op code 35 is a Load Word A
B. (4 pts.) A piece of MIPS code in your company's product includes
these lines:
check:
bne $a0, $t3, notOK
addi $v0, $0, 13
j alldone
notOK:
addi $v0, $0, 14
alldone:
...
It is discovered that the first instruction is wrong: it should have
been
bne $a0, $t4, notOK
In order to "patch" the program without making a new release of the
software, you need to figure out what the correct machine language is
for that instruction. What should the patch be (in
hex)? (The address of "notOK" is 0x400504, in case you
really want to know).
bne opcode is 0001012 (6 bits)
$a0 is 001002 (5 bits)
$t4 is 011002 (5 bits)
Offset in words to notOK from instruction following bne (PC incremented early!)
is 00000000000000102 (16 bits)
0001 0100 1000 1100 0000 0000 0000 00102 = 0x148C0002