Question

Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){...

Please do the following problems

1. translate into RISC-V Assembly

variable rpt in x19 register.

if(rpt>0){

rpt=rpt-1;

goto loop

}

2. Translate the following Risc-V code into C.

variable 'i' in register x5, variable 'result' in x6 ,base address of integer 'memarray' in x10

   addi x6,x0,0

   addi x29,x0,100

LOOP: ld x7,0(x10)

   add x5,x5,x7

   addi x10,x10,8

   addi x6,x6,1

   blt x6,x29, LOOP

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

1. We are storing 0 to x10 register for comparison to rpt variable. And x19 register is used to store rpt variable.

add x10, x0, x0 # x10=0

Loop:

bge x10, x19, Exit #if rpt <=0 then exit

addi x19, x19, -1 #rpt= rpt-1

j Loop #iterate

Exit

2. Confusion in this part of answer.

Result=0; i=0; j=0;

If(result<100)

{ i=i+a[j];

j=j+8;

result=result+1;

}

Add a comment
Know the answer?
Add Answer to:
Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){...
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