Unused labels in CA65?
Moderator: Moderators
- heardtheword
- Posts: 20
- Joined: Mon Feb 08, 2016 1:22 pm
- Contact:
Unused labels in CA65?
Is there a way to find labels that are not used in CA65? I'm trying to find code that may not be used, like dead code elimination in higher level languages. This would also help find ram storage that isn't being used.
Re: Unused labels in CA65?
I made a call graph tool as part of a code review of Thwaite in preparation for expanding the game past 16K PRG. You pass in a folder full of code, and it finds everywhere each symbol is used in order to make pretty boxes.
Call graph visualizer (using Python and GraphViz) and sample output
Call graph visualizer (using Python and GraphViz) and sample output
- heardtheword
- Posts: 20
- Joined: Mon Feb 08, 2016 1:22 pm
- Contact:
Re: Unused labels in CA65?
Nifty! I may have to incorporate this into my build process.
Thanks!
Thanks!
- rainwarrior
- Posts: 8062
- Joined: Sun Jan 22, 2012 12:03 pm
- Location: Canada
- Contact:
Re: Unused labels in CA65?
If you separate your code into multiple modules (think: 1 function defined in each .s file), and then combine them into a library, the ld65 linker is capable of identifying unused functions and automatically omitting them from the build.
The convenience of this is mitigated by having to create so many separate files, but it's available, at least. It's quite useful when linking with the CRT libraries.
The convenience of this is mitigated by having to create so many separate files, but it's available, at least. It's quite useful when linking with the CRT libraries.
Re: Unused labels in CA65?
One trick that can be used to avoid having to create many files is to do something like this (example in C, but should be adaptable to assembly).rainwarrior wrote:The convenience of this is mitigated by having to create so many separate files, but it's available, at least. It's quite useful when linking with the CRT libraries.
Code: Select all
// my_funcs.c
#if defined FUNC_FOO
int foo(void) {
return 123;
}
#elif defined FUNC_BAR
int bar(int xxx) {
return xxx+1;
}
#endif
BTW, IIRC ld65 will only drop unused object files if they come from a library. If the object file is explicitly specified in the command line it will always be included.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi