Question: Problem 2 This problem is paraphrased from an earlier edition of P&H. Consider the following code used to implement the instruction: foo $s0, $s1, $s2
Problem 2 This problem is paraphrased from an earlier edition of P&H.
Consider the following code used to implement the instruction:
foo $s0, $s1, $s2
mask: .word 0xfffff83f
start: lw $t0,mask($zero)
lw $s0,shifter($zero)
and $s0,$s0,$t0
andi $s2,$s2,0x1f
sll $s2,$s2,6
or $s0,$s0,$s2
sw $s0, shifter($zero)
shifter:sll $s0,$s1,0
Add meaningful comments to the code and write a paragraph describing how it works. Why do you suppose that writing "self-modifying code" such as this is a bad idea (and often times not actually allowed)?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
