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
Billiant! So I need to preserve only the SP! :-) Many thanks guys!
I think Eric is right. The only things that are assumed to be conserved are the SP and the currently selected register bank.
not even PSW (CY, OVF etc) Erik
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
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.
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
View all questions in Keil forum