Registers t1 has the base address of the given array and le
Registers $t1 has the base address of the given array and $ lessthanorequalto 0 is holding the value for variable y. A [500] = y + A [500] = y + A [200]; Compile the given array in C to MIPS Assembly language. Develop a program for the C expression by using MIPS assembly utility; if (i = j) B(16) = g + A(12); else A(16) = g + A(12); Assume that g is in $s0, A is in $s1, B is in $s2, i is in $t5, and j is in $t6. Compiled MIPS cod:
Solution
Question 4.
A[500]=y+A[200]
Below is the equivalent instruction of above line in assembly language
ADD $t1(500), $t0, $t1(200)
Here we are using add instruction to add $t0 which is holding the value of y and $t1(200) which is holding the value as A[200]
Question 5.
Program:
cmp $t5, $t6 ; this will compare i and j
je L1 ; je checks if instruction just before excuted was true or not. If true jump to level L1
ADD $s2(16), $s0, $s1(12) ; add
L1: ; Jump level
ADD $s1(16), $s0, $s1(12) ; add
![Registers $t1 has the base address of the given array and $ lessthanorequalto 0 is holding the value for variable y. A [500] = y + A [500] = y + A [200]; Compi Registers $t1 has the base address of the given array and $ lessthanorequalto 0 is holding the value for variable y. A [500] = y + A [500] = y + A [200]; Compi](/WebImages/12/registers-t1-has-the-base-address-of-the-given-array-and-le-1010598-1761521638-0.webp)