Search the web
Sign In
New User? Sign Up
gbadev
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
accessing memory   Message List  
Reply | Forward Message #13604 of 15019 |
Re: [gbadev] accessing memory

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





Thu Jan 2, 2003 7:41 pm

groepaz2000
Offline Offline
Send Email Send Email

Forward
Message #13604 of 15019 |
Expand Messages Author Sort by Date

i've been looking at various gba.h files and have a question about setting up memory locations. I've notived 3 main ways people are doing this.... #define...
PurpleDecay@...
Send Email
Jan 1, 2003
10:15 pm

... up ... Using this method you have an integer which still needs to be casted to a pointer, so if you want to change color entry 0 to white, you'd do: ...
Jan-Lieuwe Koopmans
jan-lieuwe@...
Send Email
Jan 1, 2003
10:36 pm

#define OBJPaletteMem ((volatile u16 *)0x5000200) Is fastest and proper. If you don't declare it volatile, the compiler may optimize out references to the...
Mike Schwartz
mykes@...
Send Email
Jan 1, 2003
10:49 pm

... 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 ...
Groepaz
groepaz2000
Offline Send Email
Jan 2, 2003
8:57 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help