Please explain with detail. Translate the following MIPS pseudo instructions int
ID: 3850197 • Letter: P
Question
Please explain with detail.
Translate the following MIPS pseudo instructions into "real" MIPS instructions. That is, show the mapping of the pseudo instructions to MIPS instructions. 1. ble Rs, Rt, Label rightarrow Branch on less than or equal: If (Rs lessthanorequalto Rt) then branch to label 2. abs Rd, Rs rightarrow Absolute: Rd = absolute-value(Rs) 3. slei Rd, Rs, Constant rightarrow Set less than or equal immediate: If (Rs lessthanorequalto Constant) then Rd = 1, else Rd = 0. 4. bgeo RS, Label rightarrow Brunch on greater than or equal to one: If (Rs graterthanorequalto 1) then branch to label 5. lwd offset (Rt) rightarrow Load a double word (64 bits) from M[Offset + Rt]. The word is loaded into registers Hi and Lo with the most significant part in register Hi and the least significant part in register lo.Explanation / Answer
Every instruction has an address which is called label.All the instructions mentioned here are similar to conditional statements like,
if
condition1 true
then goto Label.
1.) ble Rs,Rt,Label
Answer: The "ble" instruction here is compares the two registers R1 and R2. If R1 is less than or equal to R2 then it is branched to Label.This can be translated into the following:
slt $At, $Rs, $Rt (if Rs is Less than Rt then $At=1 else $At=0)
beq $At, $zero, LABEL (If the contents of the source register i.e,. $at is 0 then it branches to Label)
Here, slt-> (set on Less than) compares the 2 regiester assuming they store 32 bit.
beq->compares registers for equal values. Here, regiesters are $At,$zero
$at is the register reserved for assembler.
2.) abs Rd,Rs
Answer: The "abs" takes the absolute value of the source regiester (i.e.,rd | rs | ) Rd gets absolute value of Rs.
.This can be translated into the following:
slt Ra,Rs,$0
bne Ra,$0,neg
add Rd,Rs,$0
3.) slei Rd,Rs,Constant (set less than or equal immediate)
Answer:
Here $t0=Rd, $t1=Rs , ori uses the constant in $t0 and $at, slt compare for lessthan,beq compares for equal.
ori $t0, $zero, 1
ori $at, $zero, constant
slt $at, $at, $t1
beq $at, $zero, Done
ori $t0, $zero, 0
Done
4.) bgeo Rs,Label
Answer:
mov ax,1H (immediate constant 1 is transferred to ax)
cmp ax,1h ( compare ax vlaue with hexadecimal value 1)
je label ( if equal,then jump to label)
inc ax(increment ax)
cmp ax,1h(compare ax vlaue with hexadecimal value 1)
jg label ( if greater than,then Jump to Label)
5) lwd offset(rt)
Answer:
ld lo,offset(ax) -> Load least significant value of ax into lo
ld fi,offset(ax)->Load most significant value of ax into lo
add hi,lo -> hi=hi+lo