Question

IN MIPS AND MUST RUN IN QTSPIM

Translate the following C code to MIPS assembly code. Use a minimum number of instructions. Assume that the values of a, b, i and j are stored in registers Ss0, Ss1, St0 and Stl, respectively. Also assume that register Ss2 holds the base address of the array D. for (i=0; i<a; itt) for (i-0j<b:jt+)

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

main()
{
int a=10;
int b=10;
int D[a];
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
D[j]=i*2+j*2;
}
}

.file 1 ""
.section .mdebug.abi32
.previous
.nan legacy
.module fp=32
.module nooddspreg
.abicalls
.section .text.startup,"ax",@progbits
.align 2
.globl main
.set nomips16
.set nomicromips
.ent main
.type main, @function
main:
.frame $sp,0,$31  # vars= 0, regs= 0/0, args= 0, gp= 0
.mask 0x00000000,0
.fmask 0x00000000,0
.set noreorder
.set nomacro
j $31
move $2,$0

.set macro
.set reorder
.end main
.size main, .-main
.ident "GCC: (Ubuntu 5.4.0-6ubuntu1~16.04.1) 5.4.0 20160609"

Add a comment
Answer #2

addi St0, Szero, -1 forl tst: addi St0, $t0, 1 slt $t2, Sto, Ss0 beq $t2, Szero, exit and Stl, Stl, Szero # if $t2-0, go to e

Add a comment
Know the answer?
Add Answer to:
IN MIPS AND MUST RUN IN QTSPIM Translate the following C code to MIPS assembly code....
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