Open sy2002 opened 3 years ago
This issue steps from this comment: https://github.com/sy2002/QNICE-FPGA/issues/179#issuecomment-719987345
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()
..... _f: move #_a,R11 cmp 2,@R11 abra @R13++,!v move #_a,R12 move 2,@R12 l4: move @R13++,R15 .....
Would the compiler still generate abra @R13++,!v to return?
abra @R13++,!v
For the return itself, on the first glance this seems correct. BUT:
As described in https://github.com/sy2002/QNICE-FPGA/issues/179#issuecomment-719987345, this would be wrong, because in case of register banking, the "return statement" aka abra @R13++,!v would need to do a DECRB first.
DECRB
This issue steps from this comment: https://github.com/sy2002/QNICE-FPGA/issues/179#issuecomment-719987345
Given a C program like this:
The generated assembly for the function
f()
is: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 https://github.com/sy2002/QNICE-FPGA/issues/179#issuecomment-719987345, this would be wrong, because in case of register banking, the "return statement" aka
abra @R13++,!v
would need to do aDECRB
first.