basicv2 icon indicating copy to clipboard operation
basicv2 copied to clipboard

compiled code longer then source

Open rzo42 opened this issue 4 years ago • 1 comments

I have a file for the vic 20 that is 8k pre compiled and 21k post. The code works and I am happy as long as it functions. I just thought it was odd that the compiled code was over doubled in size. Here is the repository for the code. https://github.com/rzo42/Vic-20-Mini-Synth Thank you

rzo42 avatar Aug 12 '21 04:08 rzo42

Opps, I've somehow overlooked this one...to answer your question:

Yes, that's common. If you have to, you can work against it by using the /compactlevel directive when compiling. It will decrease the size at the expense of some performance (usually not much).

There are two main contributers to the size (apart from the fact that some things are simply more condensed in BASIC than they are in machine language): The runtime itself, which also includes a replacement for the floating point routines in ROM, which add some size (you can omit them by using the /xfloatopt directive, but the compiled code will be slower, of course). And the fact that Mospeed includes the space needed for variables and arrays in the binary as well. This isn't strictly needed in some cases but I left it in, because I need it to be there in some cases and instead of implementing some confusing logic that decides if it's needed or not, I simply include it anyway.

EgonOlsen71 avatar Nov 05 '21 11:11 EgonOlsen71