Write the following sequence of code into MIPS assembler x

Write the following sequence of code into MIPS assembler: x = x + y - z - 4; Assume that x, y, and z are stored in registers $s1, $s2, and $s3 respectively.

Solution

Given MIPS assembler: x = x - y - z - 4;
Assume that x, y, and z are stored in registers $s1, $s2, and $s3 respectively.


This is the set of instructions to be executed.
x = x - y
x = x - z
x = x - 4

SUB $d, $s, $t means $d = $s - $t;
So,
SUB $s1, $s1, $s2 //$s1 = $s1 - $s2, which means x = x - y.
SUB $s1, $s1, $s3 //$s1 = $s1 - $s3, which means x = x - z.
ADDI $s1, $s1, #-4 //$s1 = $s1 - 4 , which means x = x - 4.

Write the following sequence of code into MIPS assembler: x = x + y - z - 4; Assume that x, y, and z are stored in registers $s1, $s2, and $s3 respectively.Solu

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site