pFORTH - smartnuf/ees GitHub Wiki
To start, I read the pforth Wiki pages, and cloned the repository. I had a look over the tree, and found the VS2017 solution for the Win32 platform -- I built that, and got an executable of some 113k bytes (optimised for size).
Figuring this wouldn't be a fair comparison, I created an embedded uVision (ARM-MDK) project targeting a cortex-M3 processor (an STM32F437xx), with a minimal HAL supporting H/W initialisation and a USART peripheral, I got a baseline code size of
Program Size: Code=3644 RO-data=484 RW-data=16 ZI-data=8256
.
Adding the sources in the csrc/
directory, excluding pf_main.c
, adding csrc/stdio/pf_io_stdio.c
, copying pfdicdat_arm.h
to pfdicdat.h
, and adding the following snip to my main,
char IfInit = 0;
const char * DicName = NULL;
const char * SourceName = NULL;
pfMessage ( "\npForth Embedded\n" );
return pfDoForth ( DicName, SourceName, IfInit );
and building with -DPF_NO_FILEIO
, I got
The size of this image (79260 bytes) exceeds the maximum allowed
.
It seems the dictionary defined in pfdicdat_arm.h
, which I copied to pfdicdat.h
(because building with -DPF_NO_FILEIO
requires such a header), as when I defined these as empty (well near enough { 0 }
) (which would break everything, if it were run), I got
Program Size: Code=24766 RO-data=766 RW-data=124 ZI-data=6652
This dictionary data is likely needed (pfBuildDictionary() would normally be called to build it if no base dictionary were available) -- so our minimal size is nowhere near the 4K or so that I've seen mentioned for a FORTH REPL, it's more like 70K, and what is more much of this needs to be in RAM available on the HEAP (the dictionary is copied to malloc'd memory).
This is disappointing -- as it's origin mentions embedded systems.