Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Kick Assembler - Removal of unused code?
2019-02-05 15:04
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? :)
2019-02-05 15:25
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.
2019-02-05 15:38
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.
2019-02-05 15:58
Flavioweb

Registered: Nov 2011
Posts: 447
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.
2019-02-05 16:00
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...
2019-02-05 16:37
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.
2019-02-05 16:51
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.
2019-02-05 16:57
Zirias

Registered: Jan 2014
Posts: 48
Quoting Taskmaster
I 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.
2019-02-05 17:01
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...
2019-02-05 17:51
chatGPZ

Registered: Dec 2001
Posts: 11114
i know its not what you ask - but 64tass can do what you want, even semi automatically.
2019-02-05 18:23
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
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Acidchild/Padua
psych
Devia/Ancients
Enforcer/Deers
6R6/shape/[n0]
Durandal
Guests online: 124
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 TRSAC, Gabber & Pebe..  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Fullscreen Graphicians
1 Carrion  (9.8)
2 Joe  (9.8)
3 Duce  (9.8)
4 Mirage  (9.7)
5 Facet  (9.7)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.041 sec.