Question

(40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the require
(40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the require

its brr[8]
(40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-);
(40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program (including main and all the required directives). You can use any register. You must comply, however, with the convention of register usage. Before writing your code perform an explicit register allocation phase. Note that the C snippet is int arr[8]; int brr[4]-{1, 2, 3, 4, 5, 6, 7, 8) int i-8; while (i>-0) arrli]-brr[i-);
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot

CnusersideeptDesktopimips.asm -MARS 45 Edi Ban Selngs Iools elp Run speed at max (no inleracton) Coproc Coproc Heusters EdtProgram

#Data declaration part
.data
     arr: .word 0 0 0 0 0 0 0 0           #arr[8]
     brr: .word 1 2 3 4 5 6 7 8          #brr = {1,2,3,4,5,6,7,8}
#Program starts here
.text
#Main program
.globl main
main:
    #Get the base address of arr
    la $s0,arr
    #Get the base address of brr
    la $s1,brr
    #Initialize variable i=8
    addi $t0,$0,8
    #Address increment to get last
    addi $t1,$0,4
    mul $t1,$t1,$t0
    add $s0,$s0,$t1
    add $s1,$s1,$t1
#While loop i>=0
whileLoop:
     blt $t0,0,exitLoop
     #Get brr value into t1
     lw $t1,($s1)
     #store into arr, brr[i]=arr[i--]
     sw $t1,($s0)
     #decrement address
     addi $s0,$s0,-4
     addi $s1,$s1,-4
     #Decremnet i
     addi $t0,$t0,-1
     j whileLoop
#End of the program
exitLoop:
     addi $v0,$0,10
     syscall

Add a comment
Know the answer?
Add Answer to:
its brr[8] (40%) Convert the following C-pseudo code into MIPS assembly code as a standalone program...
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
ADVERTISEMENT