For each of the following MIPS instructions, assemble the instruction into appropriate MIPS machine code. For the instructions which are actually pseudo-instructions, first translate into an instruction or a sequence of instructions which will accomplish the result, and then assemble the resulting instruction sequence. Your final answer should be in the form of one or more eight-digit hexadecimal numbers.
add $s0, $t8, $a1ori $v0, $s1, 0x1234beq $s3, $a2, 0x400 the intent here is that the
offset be 40016 bytes from the instruction following
the beqnot $t6, $t7The first instruction generates the needed 0xffffffff, and the second does the exclusive-or. From page A-23, $t6 is $14 and $t7 is $15. Converting the two instructions gives us fields ofaddi $at, $zero, -1 xor $t6, $at, $t7
Putting them together gives8, 0, 1, ffff 0, 1, f, e, 0, 26
2001ffff 002f7026
bge $a3, $s6, 0x800 the intent here is that the
offset be 80016 bytes from the instruction following
the bgewill accomplish it. From page A-23, we have $zero is $0, $at is $1, $a3 is $7, and $s6 is $22. Converting the two instructions gives us the fieldsslt $at, $a3, $s6 beq $at, $zero, 0x800
0, 7, 16, 1, 0, 2a 4, 1, 0, 200
00f6082a 10200200
abs $t1, $t2From A-23, we have that $t1 is $9, $t2 is $10, and $zero is $0. Converting the instructions gives usaddi $t1, $t2, 0 bgez $t1, 4 sub $t1, $zero, $t1
Combining them, we get8, a, 9, 0 1, 9, 1, 1 0, 0, 9, 9, 0, 22
21490000 05210001 00094822
For each of the following MIPS machine code instructions, disassemble
the code back to MIPS assembly code. Use the register use conventions
on Page A-23 to translate register numbers (so use register
$at, not register $1).
00221820Using the conventions from page A-23, the registers translate toadd $3, $1, $2
add $v1, $at, $v0
304398c3Following the conventions from A-23, this becomesandi $3, $2, 0x98c3
andi $v1, $v0, 0x98c3
11271234Following the conventions from A-23, this becomesbeq $9, $7, 0x48d0
beq $t1, $a3, 0x48d0
ori.
Why not? Because the instruction requires the immediate
operand be 0-extended, and the only data path for it will
sign-extend it. Add a multiplexor to the data paths, and a signal to
control it from the control unit, which will make it possible.
lw $1, 100($4)
add $5, $6, $7
or $8, $9, $1
sw $8, 200($12)
or $0, $0, $0
or $0, $0, $0
or $0, $0, $0
or $0, $0, $0
or $0, $0, $0
Using Figure 6.41 as a guide, show the contents of every
control and data line in the CPU on every cycle of the execution
of this code, starting with an empty pipeline and continuing until
the pipeline is full of or instructions. Xeroxing
the figure from page 523 and marking it up, or downloading the
figure from the text website and marking it up, would be a really
good idea. Assume initial register and memory contents as in
Problem 6.10.