I found how to use one specific register bank for a function (interupt)by specifying using My_Bank and so, be faster (less PUSH and POP)but I would like to know if I can specify a variable to be located in one register bank (for speed), and, if yes, how to do it?
Only automatic variables (function-local, non-static) can be assigned to CPU registers by the compiler. Therefore, the notion of assigning a variable to a register bank makes no sense in this model. The question is, why would you want to do this?
I have some variables (coeff of a transfer function) I use in an Interrupt function and make MUL and DIV with them... I think it would be faster if this variables are stored in registers... I think I can easely affect a register of the specified bank to this variable, but the question is: how can I be sure that the C compiler whill not use these registers and then destroye my variable???
I see what you mean. For tight and fast ISRs keeping persistent variables in registers of a separate bank can speed things up. My guess is there is no way to do this in C. You'll have to use assembler for this.
Alternative might be to put the variable in IDATA. www.keil.com/.../c166_ap_locatingsections.htm Not the same as a register but you could copy the fixed location variable from IDATA to the register from your ISR. Isn't that the same as using a register bank by the way?
-- Joost
...or SDATA.
Thanks you... I will see for IDATA or SDATA...
regarding to documentation I sow that Whe can specify registers to be use in a function by @register_Mask...
but, then I must program by asm directives cause it semm whe have no acces to registers R1...R12 by C lines (offset whith CP)...
regarding to genarated code by C compiler with speed optimisation, I think I could win just 1 or 2us...
I don't know anything about your application, so I cannot tell if 2 microseconds is substantial or not. But I would avoid using non-standard C or assembler trickery unless absolutely necessary. As Donald Knuth put it, "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." Code readability is important, and you will lose some of it when optimizing. The above applies to production code. In contrast, if you are trying to push the limits of processor/compiler for educational purposes, you can probably afford some amount of messy code...
Regards, - mike
Ok, it's what I think and I say... just for 1 or 2us, it's better to to prioritys the readability of the code... I just looked for a simple way to use Registers like in the 80c196... the way seem to use IDATA like it' said below...