I've heard global vars are bad.. but, in the context of constrained devices, isn't speed a better tradeoff than tidiness? In my limited experience the only drawback is my own potential for errors (stepping on an already used var).
I think BatariBASIC has a great way to deal with multi-bank sub-routines. You can call "GOSUB FOO" for local routines and "GOSUB FOO BANK3" to tell the compiler it's located on another page.
Thoughts on Higher Level Language Design for 6502 Systems
Moderator: Moderators
It depends... if you have a lot of global variables you'll run out of RAM faster in systems that don't have much of it, like the NES, and that's a huge problem.slobu wrote:I've heard global vars are bad.. but, in the context of constrained devices, isn't speed a better tradeoff than tidiness?
IMO it's not a matter of how to call them... I mean, the compiler is the one generating the ASM/binaries, so it KNOWS what routines are in different banks, it doesn't need the programmer to explicitly say it.You can call "GOSUB FOO" for local routines and "GOSUB FOO BANK3" to tell the compiler it's located on another page.
With cc65 it's the linker that actually knows the final addresses of everything, and by then it's probably too late to insert bankswitching, at least as it is implemented. (afaik)tokumaru wrote:I mean, the compiler is the one generating the ASM/binaries, so it KNOWS what routines are in different banks, it doesn't need the programmer to explicitly say it.