This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

cc65 CONDES

cc65 CONDES
by on (#221983)
After reading though the cc65 source code, I have removed the CONDES features from my cfg files.

This will result in errors, so then

I removed any calls to initlib and donelib, from crt0.s

Errors gone.

I have run multiple tests, and find no ill effects from this.

CONDES (constructor / destructor tables) uses up several (at least 30) bytes of RAM (self modifying code).

The only function that I can see that uses this table is exit() which NES games shouldn't do.

Incidentally, CONDES seems to be the only thing that used the "ONCE" segment. CONDES may be the only thing that was responsible for all those "ONCE" segment missing errors when cc65 files updated.
Re: cc65 CONDES
by on (#221997)
The constructor side of CONDES is supposed to be for setting up init code, such that a module's init code gets called if and only if the module is linked into the ROM. On the NES, this might be useful in theory to link in PPU init or audio init or mapper init.
Re: cc65 CONDES
by on (#222015)
Yeah, I never liked that feature when it was added. A lot of extra hassle to support, and it was not put to enough use in the libraries to make it worthwhile, IMO. (And frankly I'm glad t wasn't, so that it's easier to remove like this.)

The CON point is to add an implied "init" for a module if it gets included, without having to add an extra line of C code or whatever to explicitly initialize it. The DES point is the same for shutdown, but obviously we don't need to care about that for NES.

If you just delete it from your linker configs, you're safe because anything that relies on it will produce an error. I don't think there's currently anything in the required CRT that really needs it, at least last time I looked all the modules that required it were things I'd never need on the NES. If you did need one of those constructors, you could reproduce it in your own CRT init to get support back for it.
Re: cc65 CONDES
by on (#222018)
Good to know. I've actually been wondering the same thing, and it's been on my TODO list to dig into that for a few months. Thanks!
Re: cc65 CONDES
by on (#222025)
Just to clarify some of the details.

if you don't include initlib and donelib, then the compiler doesn't include condes.s. Which means that nothing gets copied into the ONCE segment in the RAM.

Thus you can use those (35?) bytes for other things. And you also save a similar amount of ROM space.
Re: cc65 CONDES
by on (#222051)
Same thing here, I removed it as soon I understood that it was not necessary for the nes. No ill effect has long you remove what you just mentioned.
Re: cc65 CONDES
by on (#222071)
You can also use some of the regbank ZP area if your C code never uses the register keyword.
Re: cc65 CONDES
by on (#222085)
By regbank ZP, are you talking about what is defined inside zeropage.inc? I think that is the only part I didn't check much in details yet.
Re: cc65 CONDES
by on (#222207)
https://github.com/cc65/wiki/wiki/Using ... y-language
Re: cc65 CONDES
by on (#222208)
In 2.13, it shaves 66 bytes of the ROM, too, which is always good.