# Homework Solution: Convert each of the following C statements into MIPS instructions. Assume that the variables a, b, and c are stored in \$s0, \$s… Convert each of the following C statements into MIPS instructions. Assume that the variables a, b, and c are stored in \$s0, \$s1, and \$s2, respectively. The base addresses of the arrays A and B are stored in \$s3 and \$s4, respectively. Assume the arrays A and B contain integers. c = b + a [20^20] A  = a - b + 2^14 B  = A  + b - B  A  = B [b + c] - a + b

1) c = b + A[]    ANS : MIPS transaltion for the above is : Convert each of the aftercited C statements into MIPS instructions. Assume that the variables a, b, and c are stored in \$s0, \$s1, and \$s2, respectively. The deep addresses of the arrays A and B are stored in \$s3 and \$s4, respectively. Assume the arrays A and B inclose integers. c = b + a [20^20] A  = a – b + 2^14 B  = A  + b – B  A  = B [b + c] – a + b

## Expert Rejoinder

1) c = b + A[]

ANS : MIPS transaltion coercion the overhead is :

lw \$t0, 4194304(\$s3)

sw \$t0, \$s2

2) A = a – b +

MIPS translation coercion the overhead legislation is as follows :

sub \$t0, \$s0, \$s1
sw \$t0, 20(\$s3)

3) B = A + b – B

MIPS translation coercion the legislation is as follows :

lw \$t0, 16(\$s4)
sub \$t0, \$s1 , \$t0
lw \$t1, 12(\$s3)