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.
Hello, I'm working on the XC164X µc and I've a question concerning the storage of registers in stack when interrupt occur.
The function is written in c language
void ItFunc (void) interrupt 14 { funcCode (); }
The pre-processor code is as follow:
ItFunc PROC INTERRUPT = 14 GLOBAL ItFunc ; FUNCTION ItFunc (BEGIN RMASK = @0x3FFF)
SCXT DPP3,#3
PUSH DPP0
SCXT MDC,#16
PUSH MDH
PUSH MDL
MOV [-R0],R1
MOV [-R0],R2
MOV [-R0],R3
MOV [-R0],R4
MOV [-R0],R5
MOV [-R0],R6
MOV [-R0],R7
MOV [-R0],R8
MOV [-R0],R9
MOV [-R0],R10
MOV [-R0],R11
MOV [-R0],R12
; line 234: funcCode ();
CALL funcCode
?C0005:
MOV R12,[R0+]
MOV R11,[R0+]
MOV R10,[R0+]
MOV R9,[R0+]
MOV R8,[R0+]
MOV R7,[R0+]
MOV R6,[R0+]
MOV R5,[R0+]
MOV R4,[R0+]
MOV R3,[R0+]
MOV R2,[R0+]
MOV R1,[R0+]
POP MDL
POP MDH
POP MDC
POP DPP0
POP DPP3
RETI
; FUNCTION ItFunc (END RMASK = @0x3FFF)
ItFunc ENDP
?PR?BS_TST ENDS
As shown in this pre-processor code, we use the register R0 to save the registers R1—R12. I'd like to store the registers using the instruction PUSH R1. How can I do this? Which directive could I use that the compiler store the registers in stack using the instruction "PUSH R1" and not using "MOV [-R0], R1"
Thanks
Please post code in the correct way - the above text is unreadable.
There are many, many thousands of decisions the compiler makes when it generates it's code. However, that is not something you should care about, just as you shouldn't care about the algorithm for controlling the ignition system in your car.
Tou are working at the wrong conceptual level, and it doesn't matter how many questions you ask - and how many answers you receive. There will still be thousands of other issues where the compiler decides what to do, and when.
the code exist in « http://www.keil.com/support/man/docs/c166/c166_noframe.htm"
just I've made a copy of this code.
the compiler don't decides what to do, we use directives and configuration to assisit compiler what to do.
so please, the question is clear, why turn arround??
No, the compiler really do decide what to do. We write source code to inform it what we want solved, and we use directives to give it hints about how to solve it.
If it was you who decided what to do, then you wouldn't need to buy the compiler, since you would not have any need for it. The way you decide what to do, is by writing the program in assembler.
Per Westermark is refering to using the pre tags to post code on the forum.
I understand what your trying to do; give a hint to the compiler to use PUSH (system stack) instead of MOV (user stack). But it's a hint so the compiler can still decide to do otherwise.
Could you answer me/us this: -why- do you want the compiler to use PUSH instead of MOV? I don't see why it's important in the first place.
Is not important if we store registers using push or mov R0, just i'm curious to know why there are two possibility to stores registers in stack. so I think there's an option to check off to tell compiler when using push or mov R0.
thanks for advising me to use pre> to post code, it's the first time that I post in this forum.
There is checkbox in the Options for target/C166
"Save temporary variables on User Stack" If it is checked, then all registers are placed in User Stack, i.e commands like mov [-R0], Rx are used. If unchecked, then push/pop commands are used instead.
Thanks Andrey!
For those people who do not use the IDE :-) it's the SAVESYS and SAVEUSR compiler directive. I completly missed those...
See http://www.keil.com/support/man/docs/c166/c166_cm_directives.htm
Thanks MOMO, I learned something new because of your post.
-- Joost
yes, finally
thanks for you