Question: 1 7 . Translate following C + + code to MIPS assembly language: * Write down your comment after ## int main ( ) {
Translate following C code to MIPS
assembly language:
Write down your comment after ##
int main
int x;
for int i; i; i
xi i;
x: space ## Reserve space for integers bytes bytes
text
globl main
main:
# Initialize i to
li $t ## $t i
loop:
# Check if i
li $t ## $t
bge $t $t endloop ## if i exit loop
# Calculate address of xi
sll $t $t ## $t i shift left logical by to multiply by
la $t x ## load address of x into $t
add $t $t $t ## $t address of xi
# Store i into xi
sw $t$t ## xi i
# Increment i
addi $t $t ## i
# Jump back to the beginning of the loop
j loop
endloop:
# Exit the program
li $v ## Load the exit code into $v
syscall ## Make a system call to exit
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
