spotlessmind1975 / ugbasic

An isomorphic BASIC language compiler for retrocomputers
Apache License 2.0
92 stars 16 forks source link

Migrate inline code to library call on demand #134

Closed spotlessmind1975 closed 3 years ago

spotlessmind1975 commented 3 years ago

Once put to work, the compiler proves to be inefficient from the point of view of the space occupied.

In fact, if we exclude the need to introduce portable mechanisms to differentiate the data memory banks from the code ones, the code itself is not very optimized in terms of size. It is therefore required to introduce an option (-e) to allow the use of embedded libraries instead of inline code.

Since this implies a deterioration in performance, every single function must be registered with a code, which must be indicated to suggest to the compiler to replace the inline code with a function call.

I.E.:

../ugbasic/ugbc/exe/ugbc.c64 -e cpumul8,cpufill -o main.prg main.bas

Where:

spotlessmind1975 commented 3 years ago

A first version was implemented for the CPU 6502, and the savings were about 10% compared to the size of the original executable. The scheme is to provide, for each function point, two versions of the same code: the first is the inline version (already coded) while the second is the embedded version.

By definition, the embedded have been activated for the following function points:

The activity should be exentended to the remaining CPUs: