We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
We have an assembler function, which when called from C, some or all registers may be trashed. Saving and then restoring them is an option but it takes too much RAM. Is there a directive which tells the compiler that registers may be trashed when a certain function is called? Thanks in advance, Gary Partis
Basically the Keil C assume that any function trashes all registers. A simple way to handle it is to write a skeleton function in C and use the generated assembler source as a base for the assembly routine (it will include comments re register use) Erik
Keil C assumes that any function trashes all registers Note the $REGUSE control in the assembly manual, if you want to help out the C optimizer by telling it the registers your assembly function actually uses, so it need not make this worst-case assumption.
Hi guys, thanks for the information! :-) So to confirm, if I dont use the REGUSE directive, the C compiler will assume all registers (except PSW and SP of course) may be trashed? Thanks in advance, Gary Partis
not even PSW (CY, OVF etc) Erik
I think Eric is right. The only things that are assumed to be conserved are the SP and the currently selected register bank.
Billiant! So I need to preserve only the SP! :-) Many thanks guys!