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?
If you want Control, use assembler, if you want programming ease, use C. Do not ask for both, It aint possible. That's funny, I use the #pragma ASM directive and I can get both assembler and C to compile with ease. Aloha, After looking a bit more on the forum I discovered something too. Erik is everywhere on this forum being grumpy and uppity with everyone else. Chill out man! You ain't nothing but a hound dog! This is a forum aimed to help, not condescend. I need all the help I can get. The transition from king of rock n roll to microcontroller programmer ain't easy! Thanks Elvis A Presley
I am not being grumpy I am being direct and to the point. If someone need an answer, they get it but no "I am sorry if you would rather do it wrong, I understan your dilemma" Erik
Well I understand where your coming from, and you were somewhat helpfull. Besides I never liked Elvis Presley I was always and Eddie Cochrane fan.
"That's funny, I use the #pragma ASM directive and I can get both assembler and C to compile with ease." Not really. You're just making the compiler convert the whole source file to assembler - you still have no control over precisely what assembler mnemonics the compiler will use! You also throw away lots of other things that the compiler would otherwise give you - like source-level symbolic debugging. "After looking a bit more on the forum I discovered something too. Erik is everywhere on this forum being grumpy and uppity" Instead of searching out contributors' character traits, try searching for discussions of inline assembler - you will find plenty of cause to be grumpy about it...!
Using "#pragma asm" directives can cause big troubles, belive me! Compiling through asm is very buggy! For example, try to create a function with many params in C51 v6.20, and if u'll compile this prog through asm it will not work! In C51 v7.00 it was fixed, but do anybody know what bugs were added? ;)
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);
I'm all shook up Have a good weekend guys. I'm off to Hawaii. The King
"I'm all shook up Have a good weekend guys. I'm off to Hawaii. The King" Try and stay off the burgers.