I would like to change the order that some of the registers are stored on the stack when an interrupt occurs. Ideally I would like to store the IE register first. Does anyone know if it is possible to stop the C51 compiler from pushing and poping registers from the stack automatically in an interrupt routine, so that I can do this manually, in the order I would like?
I thank you all for your help. I understand the principle that using assembler gives you more control, I can and do write in assembler. The biggest problem with assembler is it costs me more time, I don't want to upset all of you that are as quick with assembler as they are in C, I am not. As they say in business time is money. The interrupt routines of the C51 compiler have made life simpler and quicker and often totally remove the need to write assembler. It also makes life easier for new staff to grasp what is happening in code that is new to them. As a result I generally attempt to write everywhere possible in C. This whole subject came about as the new C51 compiler (v7.20) supports the new intrinsic functions push() and pop(). Where I had assembler, I could now replace it with C, if only I could turn off the compilers automatic pre and post pushing and popping of registers, like the C166 compiler does with the NOFRAME directive. This would be a complimentary addition to the push() and pop() functions. This would result in me having an all C interrupt routine which would make it easier and quicker for me to add and debug any changes I make.
"This would result in me having an all C interrupt routine which would make it easier and quicker for me to add and debug any changes I make." I don't really understand. If you write the ISR in 'C', you don't know what needs to be stacked, the compiler does, and it only preserves registers that it destroys in the ISR. Why would you want to interfere with that mechanism? Why would you want to push/pop IE anyway? You can specify a register bank for an ISR with the 'using' directive which may reduce the amount of stuff that gets stacked. Could you explain why you are trying to do this?
Why would you want to push/pop IE anyway? Well, since I do it I'll tell you why
OLD local U8 saveIE; SaveIE = IE; EA = FALSE; .... IE = save IE; NEW: Push(IE); EA = FALSE; .... Pop(IE);