Jump to content

Guide To Inline Assembly And Register Saving

Recommended Posts

I am experimenting with the inline assembly feature of the BoostC compiler. I would like to work with certain registers, but I don't know if I need to save their values or not. I know I could do it to be safe, but some of these are very time critical and I don't want to save unnecessarily. Is there a guide somewhere about what registers BoostC uses for internal purposes or provides guidelines for which registers can be safely modified without saving?


In particular I'd like to deal with FSR registers. I know some PIC compilers use these for software stacks and occasionally loop or other rapid indexing situations. From code I've compiled it looks like BoostC itself is generating code that uses FSR0 without saving it, but I'm also not using a software stack at the moment. I would like a solution that isn't likely to break as I expand the project, but realize that may be too much to ask :)



Link to post
Share on other sites

BoostC is a C compiler with an assembler as an add-on feature. As such the compiler is free to use whatever registers it requires to produce the most efficient code. As there is really no way of knowing what registers the compiler is using any assembler functions or inline code should preserve what it uses.


Looking at the interrupt code, only FSR0, as well as the usual registers, is saved. This may say that the other FSR registers are not used by the compiler. This may not be the case in the future.


Tread with care.





Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...