It is currently Wed Oct 17, 2018 8:51 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: cc65 CONDES
PostPosted: Wed Jul 25, 2018 6:14 am 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2304
Location: DIGDUG
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.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Last edited by dougeff on Wed Jul 25, 2018 12:20 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Wed Jul 25, 2018 8:26 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20662
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Wed Jul 25, 2018 11:45 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 6887
Location: Canada
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.


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Wed Jul 25, 2018 12:15 pm 
Offline
User avatar

Joined: Fri Nov 24, 2017 2:40 pm
Posts: 82
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!


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Wed Jul 25, 2018 12:59 pm 
Offline
User avatar

Joined: Fri May 08, 2015 7:17 pm
Posts: 2304
Location: DIGDUG
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.

_________________
nesdoug.com -- blog/tutorial on programming for the NES


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Wed Jul 25, 2018 4:08 pm 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2004
Location: Fukuoka, Japan
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.


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Thu Jul 26, 2018 3:48 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 810
You can also use some of the regbank ZP area if your C code never uses the register keyword.


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Thu Jul 26, 2018 6:16 am 
Offline
User avatar

Joined: Tue Jun 24, 2008 8:38 pm
Posts: 2004
Location: Fukuoka, Japan
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.


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Fri Jul 27, 2018 3:13 am 
Offline

Joined: Tue Oct 06, 2015 10:16 am
Posts: 810
https://github.com/cc65/wiki/wiki/Using ... y-language


Top
 Profile  
 
 Post subject: Re: cc65 CONDES
PostPosted: Fri Jul 27, 2018 3:56 am 
Offline

Joined: Mon May 27, 2013 9:40 am
Posts: 494
In 2.13, it shaves 66 bytes of the ROM, too, which is always good.

_________________
http://www.mojontwins.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group