| |
Taskmaster Account closed
Registered: Feb 2018 Posts: 22 |
Kick Assembler - Removal of unused code?
I'm trying out Kick Assembler and I'm wondering if it has a feature I used a lot in my own assemblers over the years.
I like to collect useful subroutines and keep them in an external ASM file that I include at the top of my code. Is there a way that I can do that BUT have the assembler not compile code that I don't actually call?
I hate to eat the memory space for stuff that I won't be calling in that specific app.
How do you guys handle this sort of thing? Am I over engineering? :) |
|
| |
Zirias
Registered: Jan 2014 Posts: 48 |
A feature you used a lot? How would that work? While it's relatively easy to detect definitely "dead code" in C, I don't see how an assembler could reliably do that, e.g. think about self-modification with calculated jump targets...
With ca65, you could take advantage of the linker (ld65): have each of your routines in a separate translation unit, pack them into one static library with ar65. When you link this library, the linker will only include object files with code that is actually referenced. You can have an include-file with this library that has all the ".import" statements necessary -- ca65 discards ".import"s that aren't actually used. |
| |
Taskmaster Account closed
Registered: Feb 2018 Posts: 22 |
In my case, I had a special way to designate routines that were optional for compilation. So something like:
.sub MyFunc
{
}
If "jsr MyFunc" never appears in the code, then it excluded that subroutine from the final compilation.
So I guess I could reframe the question to be something like:
How does someone with lots of little utility functions organize their code base? Do you simply copy/paste the stuff you need in?
I thought about some sort of system where every sub routine lived in it's own ASM file but that seems crazy. |
| |
Flavioweb
Registered: Nov 2011 Posts: 463 |
I guess you can use IF statements with some flags in your init part where set them to 1 when used functions need to be compiled. |
| |
Taskmaster Account closed
Registered: Feb 2018 Posts: 22 |
I had thought of that. Seemed clunky so I was hoping maybe Kick had something to automate the process but I guess not.
Thanks for the replies! I'll work around... |
| |
Erol
Registered: Jul 2003 Posts: 6 |
Macros and pseudo-commands in separate .asm file please check http://www.theweb.dk/KickAssembler/webhelp/content/cpt_Function.. if you don't call it via macro or pseudo command it will not get compiled, so only used macros and pseudo-commands are actually compiled and present in memory. |
| |
Taskmaster Account closed
Registered: Feb 2018 Posts: 22 |
Thanks! Yes, macros and pseudocommands work the way I want but that doesn't fly if the routine is somewhat large. I don't want to macro it into the code everywhere I call it ... say, for example, a memcopy routine.
In that case, I want to make it a routine that compiles once in memory BUT gets ignored if nobody calls it.
Functions don't really fly because they can't generate byte code. Just the internal scripting commands are allowed. Unless I missed something. |
| |
Zirias
Registered: Jan 2014 Posts: 48 |
Quoting TaskmasterI thought about some sort of system where every sub routine lived in it's own ASM file but that seems crazy.
Why? At least with something like ca65, it isn't -- you can have something "self-contained" (with code, data, bss, zeropage segments) and only link it when needed. To use it, you build a static library from all these files.
When working only at the source level, it's of course a bit more cumbersome. |
| |
Taskmaster Account closed
Registered: Feb 2018 Posts: 22 |
I should have been clearer - crazy for ME. :) I'm not that advanced at this point, so doing all of that is sort of beyond my scope at the moment.
But thanks, it's good to know that sort of thing is possible... |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
i know its not what you ask - but 64tass can do what you want, even semi automatically. |
| |
Taskmaster Account closed
Registered: Feb 2018 Posts: 22 |
No, that's super helpful, thanks!
.proc
.pend
That looks like what I want. I'll dig into 64tass a little then, maybe that's a better fit for me. |
... 20 posts hidden. Click here to view all posts.... |
Previous - 1 | 2 | 3 - Next |