Question

Convert the program you wrote in to an MIPS assembly program. Make sure that you show...

Convert the program you wrote in to an MIPS assembly program. Make sure that you show the symbol table (assume memory is allocated beginning address 5000) and that the equivalent assembly program is commented.

int main() {

int a[10];

int i = 0;

while( i <= 5) {

a[i]=i;

a[9-i]=9-i; i++;

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

MIPS assembly program :

======================

.data
a: .word 0,0,0,0,0,0,0,0,0,0

.text
.globl main

main:
la $s0,a # address location for a(0)
li $t0,0           # int i=0
loop:
bgt $t0,5,done       # loop till i<=5
mul $t2,$t0,4       # calculating offset address
add $s1,$s0,$t2       # address location for a(i)
sw $t0,0($s1)       # a(i)=i
sub $t1,$t0,9       # i-9
mul $t1,$t1,-1       # -(i-9)=9-i
mul $t2,$t1,4       # calculating offset address
add $s1,$s0,$t2       # address loaction for a(9-i)
sw $t2,0($s1)       # a(9-i)=9-i
add $t0,$t0,1       # i++
j loop
done:
  
# exit program
li $v0,10
syscall
====================

Add a comment
Know the answer?
Add Answer to:
Convert the program you wrote in to an MIPS assembly program. Make sure that you show...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT