Submission Instructions: Translate the following MIPS pseudo instructions into “
ID: 3902850 • Letter: S
Question
Submission Instructions:
Translate the following MIPS pseudo instructions into “real” MIPS instructions. That is, show the mapping of the pseudo instructions to MIPS instructions. Note that the only register you can use as temporary is register $at ($1). (the meaning of the symbol ‘||’ is that the order of the operations does not change the result of the operations.
1. ble Rs, Rt, Label
?Branch on less than or equal;
If (???? ? ????) then branch to label
2. abs Rd, Rs
?Absolute;
Rd = absolute-value (Rs)
3. slei Rd, Rs, Constant
?Set less than or equal immediate;
If (???? ? ????????????????) then ???? = 1, else ???? = 0.
4. bgeo Rs, Label
?Branch on greater than or equal to one;
If (???? ? 1) then branch to label
5. swapr Rs, Rt
?Swaps the contents of registers Rs and Rt
Rs?Rt || Rt?Rs
6. swapm (Rs), (Rt)
?Swaps the contents of the memory locations pointed to by registers Rs and Rt
M[Rs]?M[Rt] || M[Rt]?M[Rs]
Explanation / Answer
1. ble Rs, Rt, Label - Branch on less than or equal;
beq $Rs,$Rt,Label
2. abs Rd, Rs - Absolute
sra $Rd,$Rs,31 xor $Rs,$Rs,$Rd sub $Rs,$Rs,$Rd
3. slei Rd, Rs, Constant - Set less than or equal immediate
slt Rd, Rs, $1 # here $1 stores the value of constant
4. bgeo Rs, Label - Branch on greater than or equal to one;
bge $Rd, $Rs, Lb1 # Here Rs will hold value 1