On Wednesday 01 January 2003 23:37, Mike Schwartz wrote:
> #define OBJPaletteMem ((volatile u16 *)0x5000200)
>
> Is fastest and proper. If you don't declare it volatile, the compiler
> may optimize out references to the memory in ways you don't want. This
> #define doesn't use a memory location, like the third declaration below
> does, and requires one less indirect memory fetch (is faster).
while that statement is true for some cisc-cpus, it doesnt apply to most (if
not all) risc cpus.... ie, risc-cpus always do memory access indirect anyway
and thus for the speed of the generated code it doesnt make a difference
which of the former mentioned methods is used.
however, other than the rest i would really recommend using the third method
(through a -visible in C code- pointer), since this will result in your code
using _one_ pointer for _all_ these acesses (as a sideffect making it easy to
abuse that pointer for doublebuffering or sth) instead of inserting that
pointer into the code everytime its beeing used. (this will happen with gcc
atleast, no idea if ads can optimize this out).
--
___ ___ .___________________ .___________ _______.
c=64 / | \| \__ ___/ \ \_ _____/ \ \ [groepaz]
gb / ' \ | | | / \ / \ | __)_ / | \ gp32
cgb \ . / | | |/ ' \| \/ | \ psx
gba \___|_ /|___| |____|\____|__ /_______ /\____|__ / dc
-----\/-----'---------------\/--------\/---------\/
http://www.hitmen-console.org Hitmen WWW Headquarters
http://fly.to/hitmen-groepaz my personal playground
http://rr.c64.org/silversurfer home of the RR debugger
ftp.musoftware.de/pub/groepaz cc65 dump site