Ask your own question, for FREE!
Computer Science 14 Online
mhchen:

I hate doing this problem so I'm just gonna type it here: Do this in Y86 code: long i = 0 if(i>=last) goto done

mhchen:

``` irmovq $0,&rbx #long i = 0 ```

mhchen:

last is in %r12

mhchen:

Plan: Store (last) on stack Do last - i ==> last Restore (last) from stack => last if last - i >=0 then last >=i so i must check if last - i <= 0 so last <= i ``` irmovq $0,%rbx subq 8,%rsp #make room on stack rmmovq %r12,(%rsp) subq %rbx,%r12 #last = last - i jump if less than or equal to done mrmovq (%rsp),%r12 addq 8,%rsp #clear room on stack ```

mhchen:

lol this hurts my brain so much

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!