Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The book asks to translate this c++ code to MIPS assembly language and make it r

ID: 3745737 • Letter: T

Question

The book asks to translate this c++ code to MIPS assembly language and make it run in a 64 bit enviorment. I already made a 32 bit version but dont know what is needed to make it run in a 64 bit enviorment.

This is what i have so far:

slt $t3, $s5, $zero

bne $t3, $zero , Exit

slt $t3, $s5, $t2

beq $t3, $zero , Exit

add $t1, $s5, $s5

add $t1, $t1, $t1

add $t1, $t1, $t4

lw $t0, 0($t1)

jr $t0

L0: add $s0, $s3, $s4

j Exit

L1: add $s0, $s1, $s2

j Exit

L2: sub $s0, $s3, $s4

j Exit

L3: sub $s0, $s1, $s2

Exit:

Example: Compiling a switch Statement using a Jump Address Table. Consider the code: switch (k) case 0: f = i + j; break ; /* k = 0* case 1: f g + h; break ; /* k = 1*/ case 2: fg - h; break; /* k2*/ case 3: f i - j; break ; /* k3* Assume the six variables are contained in registers $s0 to $s5 and that register $12 contains 4.

Explanation / Answer

Hello ,

In the above question , The same code Assembly code is capale enough to get executed on x64 architechture . The main difference between 32 and 64 bit is the register size and the address space of a processor.Unless you are executing a far jump instruction/addressing the raw memory ,It is not an issue(Which you are not doing here). Hence,your MIPS should not create any issue on 64 bit.