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

Library doesn't preserve IY register in SMSlib_PSGaiden.c #5

Closed
aralbrec opened this issue Apr 3, 2017 · 4 comments
Closed

Library doesn't preserve IY register in SMSlib_PSGaiden.c #5

aralbrec opened this issue Apr 3, 2017 · 4 comments

Comments

@aralbrec
Copy link

aralbrec commented Apr 3, 2017

Unless programs are compiled with the --reserve-regs-iy flag, SDCC expects the IY register to be preserved across calls just like IX.

In SMSlib_PSGaiden.c, IY is used but is not saved. IX is saved.

@sverx
Copy link
Owner

sverx commented Apr 4, 2017

According to the SDCC manual, if I got the meaning correctly, it should be the other way around.
As we're not using the --reserve-regs-iy flag, IY can be used as a temporary register, as written in section 4.3 of the manual:

Register A, B, C, D, E, H, L and IY are used as a temporary registers for holding variables.

@aralbrec
Copy link
Author

aralbrec commented Apr 5, 2017

I mistyped there - in the above I meant the --reserve-regs-iy flag which I have corrected in the original post.

Despite what the manual says, I have come across instances where sdcc has used an old IY value across a function call that did not indicate IY was preserved. I tried some test compiles tonight to try to find an example without success but I will continue to try a few more and see if I can find an example.

@sverx
Copy link
Owner

sverx commented Apr 5, 2017

If you find that some generated code is assuming that IY is unchanged after a call, then it might be an SDCC error - or you might have called a function that has a __preserves_regs( ) declaration attached to it.
In either case please let me know. I'm leaving this open for your feedback :)

(I also edited my last post to fix that --reserve-regs-iy)

@sverx sverx closed this as completed May 2, 2017
@sverx sverx reopened this May 2, 2017
@sverx
Copy link
Owner

sverx commented May 2, 2017

closing this

@sverx sverx closed this as completed May 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants