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

Mips (assembly language) I am stuck on how I can write the machine language repr

ID: 3675923 • Letter: M

Question

Mips (assembly language)

I am stuck on how I can write the machine language representation of each instruction in binary. for the following code segment. The instruction codes are add->32,beq->4,addi->8,

      lw->35,j->2. Asume that Loop has the address of Ox4CB23

            Loop:

                        beq      $t1, $t2, done

                        lw        $s1, 0(($t0)

                        add      $s0, $s1, $s0

                        addi     $t1, $t1, 1

                        j           Loop

            done:

Explanation / Answer

Hi try with the below mentioned instruction for your reference,

Loop: slt $t0,$0,$a1

beq $t0,$0,Exit

add $v0,$v0,$a0

addi $a1,$a1,-1

j Loop

Exit:

For creative translate to C code

$v0: var1

$a0: var2

$a1: var3

var1 = 0;

while (var3 > 0)

{

var1 += var2;

var3 -= 1;

}