0

I need to know what is the value of x12 knowing that x13=10 ( without using rars ) these are the code lines

loop:
blt x13,x0,EXIT
addi x13,x13, -1
addi x12,x12,2
jal x0, loop
exit:
exiturnor
  • 57
  • 1
  • 5
  • Don't just ask us to solve your homework or quiz problem. You can read about each instruction in the manual. If you're confused by something, then ask about that instead. And what's wrong with using RARS? You can ask the internet but can't use RARS? – Erik Eidt Jul 15 '21 at 16:35
  • Hi Erik, there is nothing wrong with using rars, but I do have a teacher who did not give us any basis to read the RISC-V manual and as if that were not enough he does not make us use rars. I just wanted to understand how I had to do the exercise. That's it. – exiturnor Jul 15 '21 at 16:46
  • The manual is online, you can read it and ask if you have questions on it. RARS is free, you can use it to supplement your understanding. Asking for solution to homework or quiz problem *without showing your attempt* is off topic here. – Erik Eidt Jul 15 '21 at 17:01
  • Okay, sorry, my bad. – exiturnor Jul 16 '21 at 07:05

1 Answers1

1

This is the loop with the counter x13. So you do 11 iterations and increase x12 by 2 in each iter.

If x12 was initialised with 0, then it will equal 22 after the loop.

Below is C equivalent of your code.

while(1) {
    if (x13 < 0)
        break;
    x13 -= 1;
    x12 += 2;
}

or

for (int x13 = 10; x13 >= 0; x13--)
    x12 += 2;
BEANefiT
  • 56
  • 3