??? 09/20/04 07:57 Read: times |
#77688 - RE: My USING experience Responding to: ???'s previous message |
hi,
It seems, that C can not be forced to hold global variables in registers. It may be forced to hold global variables in memory space where registers are located in. For example, to obtain registers of bank1 we do data struct { unsigned char areg0; unsigned char areg1; unsigned char areg2; } regs_of_bank1 _at_ 0x08; Unfortunately, compiler does still not "know" that this area is registers. If we switch to bank 1 and try to use one of these variables, then c-compiler does not generate registers access but still memory one. Moreover, it probably will trash the contents of some variables because c-compiler may use any registers of the current bank without user notification. But the situation changes if you use assembly routines which utilize registers. For example, main() is in C-language and it controls the contents of structure shown above. At the same time, an interrupt service routine is in ASM. There it switches to register bank 1 and then utilizes registers which are variables of the structure. We use such way here to hold variables in registers for some ISRs which require high speed. Regards, Oleg |