Hello, in my application I use often a global variable. Since this variable is use in lots of functions, I'd like to assign it to a specific register (like DR28). It is possible? If yes, how can I do such a thing? Thanks
If you use a global variable (long, an array etc..), assign it to a local variable in the function at function entry and move the value back to the global variable at function exit. This way you can come very close to your request. Here is a portition of code taken from an interrupt routine that is speed optimized (dual channel software tone generator for ISDN S0 bus) 64 PCM tone samples have to be copied to FIFO as fast as possible: Two dimensional global array:
static unsigned int tone_idx[2];
... idx = tone_idx[chan]; for (i = 64; i; i--) { /*** DDS - Circular buffer fashion ***/ idx += fr; if (idx >= 1000) idx -= 1000; /*** Copy tone samples to FIFOB ***/ *fifob = PCM_Tab[idx]; } tone_idx[chan] = idx; ...
Thank you very much for your answers. I've tried it and it reduce my code size. Thanks again Vincent