compiled size

Questions and discussion about the ZBasic IDE.
Post Reply
DH*

compiled size

Post by DH* »

I have a >2550 line BX-24 project which compiled to ~26K with BasicX.

It compiles to 16K with ZBasic.

Is this for real?
mikep
Posts: 796
Joined: 24 September 2005, 15:54 PM

Post by mikep »

Yes this is for real. ZBasic produces much more compact code than BasicX. The reason is that many functions in BasicX are expanded out to inline code. BasicX has 122 system library functions, 48 of which are implemented as extra code.

ZBasic has a much larger flash memory so these functions and more are all implemented in the runtime - hence the compiled code is much smaller.

I have examined the details of the BasicX internals and explain more about this in part 3 and part 4 of my series of articles http://home.austin.rr.com/perks/micros/Articles/.
Mike Perks
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

The size difference that you observed is atypical. It is more common to see a reduction in the 10% to 25% range but in some cases I have seen a very large difference and in some, virtually no difference.
- Don Kinzer
DH*

Post by DH* »

I'm impressed. I use the free EEPROM for data and was hoping to gain 1-2K but this will let me add some desired features as well.
DH*

Post by DH* »

Now I'm confused.

With BasicX the reported compile size and .bxb file size were the same. With ZBasic the IDE reports 16K but the .zxb file is 47K.
dkinzer
Site Admin
Posts: 3120
Joined: 03 September 2005, 13:53 PM
Location: Portland, OR

Post by dkinzer »

With BasicX the reported compile size and .bxb file size were the same. With ZBasic the IDE reports 16K but the .zxb file is 47K.
That's because with BasicX the .bxb file is a memory image whereas with ZBasic the .zxb is an Intel Hex format file. This standard format (with some extensions) was chosen because it is checksummed. The disadvantage is that downloading takes longer.

Each record holds a maximum of 16 data bytes and there are 13 bytes of overhead for each record. Consequently, the size of a .zxb file will be approximately (size * 2) + INT((size +15) / 16) * 13.
- Don Kinzer
Post Reply