From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-01-20 07:16:53
Good morning! Sorry for the delay, I'm still very busy with my new flat, so please bear with me. On Sat, Jan 18, 2003 at 02:21:07AM +0100, Stephan Lesch wrote: > is there a way to use statically-declared register variables? There are some ways, but using the "register" keyword is none of them. The compiler accepts the "register" keyword for globals (as well as "auto"), but this is an error in the compiler - it should issue an error message, but does not. The problem is fixed, see the "Known Bugs" page. Using static zero page locations: 1. Use numeric addresses and hide them behind a define: #define XPos (*(unsigned char*)0xFC) ... XPos = 3; 2. Declare the variables in an assembler module, export them using ".exportzp", and tell the compiler using the "#pragma zpsym" statement: ------------------foo.s--------------- .exportzp _XPos .zeropage _XPos: .res 1 -------------------------------------- ------------------bar.c--------------- extern unsigned char XPos; #pragma zpsym ("XPos") XPos = 3; -------------------------------------- You may have to change the linker config when using this method, because the standard zeropage segment does not have any space left, so the variable declared in foo.s will generate a segment overflow. Note that all this is not portable, neither to other C compilers, nor between the supported machines (because of the zero page address used). > I tried it with V 2.9.0, but the register vars declared on top level are > mapped to the same zp location: This is because the compiler should not accept the declaration in the first place. Regards Uz -- Ullrich von Bassewitz uz_at_musoftware.de ---------------------------------------------------------------------- To unsubscribe from the list send mail to majordomo_at_musoftware.de with the string "unsubscribe cc65" in the body(!) of the mail.
This archive was generated by hypermail 2.1.3 : 2003-01-20 07:17:22 CET