Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VBCC: Check edge case around abra @R13++,!v #186

Open
sy2002 opened this issue Nov 8, 2020 · 0 comments
Open

VBCC: Check edge case around abra @R13++,!v #186

sy2002 opened this issue Nov 8, 2020 · 0 comments
Assignees
Labels

Comments

@sy2002
Copy link
Owner

sy2002 commented Nov 8, 2020

This issue steps from this comment: #179 (comment)

Given a C program like this:

int a;
   
void f()
{  
   if (a < 2)
   {
      a=2;
   }
}
   
int main()
{  
   a = 1;
   f();
}  

The generated assembly for the function f() is:

.....
_f:
   move  #_a,R11
   cmp   2,@R11
   abra  @R13++,!v
   move  #_a,R12
   move  2,@R12
l4:
   move  @R13++,R15
.....

What if we force the compiler to use register bank switching instead of the stack?

Would the compiler still generate abra @R13++,!v to return?

For the return itself, on the first glance this seems correct. BUT:

As described in #179 (comment), this would be wrong, because in case of register banking, the "return statement" aka abra @R13++,!v would need to do a DECRB first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants