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

Translate the following expression into MIPS assembly language. Use less than 6

ID: 3747762 • Letter: T

Question

Translate the following expression into MIPS assembly language. Use less than 6 instructions. For division, assume that there is no remainder. You can use temporary register such as St0 if needed. 4. 1) StO Ss0/4-5 2) abs Ss1, Ss2 mult & div' instructions abs(Ss2], abs[Ss2]' is an absolute value of Ss2. 5*Ss1 do not use Ss1 - implement 2 cases (positive and negative) using beq. ; Assume that there is no remainder for the division. ; 12345678 (decimal) = 188 x 216+24910 3) Ss1-(1-Stl)(1+St1) you can use temporary registers, 4) Ss0 12345678

Explanation / Answer

a) Using Logical Shifting:

$t0 = $s0/4 // This division operation is equivalent to right shift by 2 position.

$t0=$s1*5 // This operation is equivalent to [left shift by 2 + $s1].

1. sll $s1 $t1 2 ; // Shift s1 by 2 position or s1*4;

2. sll $t3 $t1 $s1 ; // add $t1 with $s1 and result stored in $t3;

3. srl $s0 $t4 2; // divide s0 by 4 and result stored in $t4;

4. sub $t0 $t4 $t3 ; // subtract 5*$s1 from $s0/4 and result stored in $t0;

b)

1. ori $t1, $zero, $s2      #copy s2 into t1

2. slt $t2, $s2, $zero      #is value < 0 ?

3. beq $t2, $zero, foobar #if t2 is positive, skip next inst

4. sub $s1, $zero, $s2      #s1 = 0 - s2

5. foobar:                 # label

c.)

188 Hexadecimal Representation = 188 =(0000 0000 1011 1100)2 = (00BC)16

24910 Hexadecimal Representation = 24910 = (0110 0001 0100 1110)2= (614E)16

1. lui $s0,0x00BC // Load Upper 16 bits s0[31-16] with 188

2. addi $s0,$s0,0x614E; // Add Lower 16 bits from s0[15-0] with 24910

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote