Question: Translate the following C statement to an equivalent MIPS assembly program. Assume that the variables f, g, h, i, and j are assigned to registers

Translate the following C statement to an equivalent MIPS assembly program.

Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively.

Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively.

B[8] = A[ij]; // C code

You must use the following template to fill in the MIPS codes for the translation of the above C code.

Also, you must add the comments for each line of MIPS codes you add.

.data

A: .word 0x1234 : 8

.word 0xABCD : 8

B: .word 0x0 : 16

.text

li $s0, 0 # f=0

li $s1, 1 # g=1

li $s2, 2 # h=2

li $s3 3 # i=3

li $s4, 0 # j=0

la $s6, A # base address of Array A

la $s7, B # base address of Array B

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!