Shop Learn P1 Docs P2 Docs
Towards "aPropOs", a Self- Hosted System for P2 with a small C-Compiler? — Parallax Forums

Towards "aPropOs", a Self- Hosted System for P2 with a small C-Compiler?

Hi,
as we had some discussions about self hosted systems, I thought to give some information here.

This is based on Eric's shell and file system provided with FlexProp. And the idea is to use the C-Compiler from Robert's SWIEROS https://github.com/rswier/swieros/blob/master/root/bin/c.c
This is a "small" c compiler that can handle quite a few things like floats. It can compile itself. Though I don't know, if that is possible on a P2.
It compiles to "b-code". This code is 32bits containing 8 bit code and 24bit data like constants or addresses. This code is fully relocatable together with their variables space. Code- files are named file.b .

At the moment I have achieved

  • to compile the compiler (with MinGW) to ct.b (63kB) (t stands for target) with smaller data space.
  • to integrate the b-code interpreter into the shell and to modify the includes for that purpose.
  • b.code programs can be executed from the shell:
  • They do not need much space, because the shell acts like a dll. hello.b has 5kB.
  • When a b-code program is launched, stack space and b-code space is allocated. At the moment I have reserved16kB stack space. (In SWIEROS this is set to 8MB)
  • The c-compiler needs about 200kB of Ram from heap for a small program.
  • It is not easy to find bugs in this constellation. The c-compiler gives scarce information.

The speed is very roughly for a simple fibonacci benchmark:
b.code : Flexprop-Hubexec +globals : FlexProp+fcache+locals = 1:7:60

The b-code interpreter, which is written in c, is translated well to Pasm, as far as I am able to judge. Have seen no quick wins.

At the moment I am wondering, if and how to proceed. I do not know a way to integrate a P2 assembler. There is a b-code assembler available.

Comments

  • roglohrogloh Posts: 4,617

    Sounds interesting. Have you considered a P2 VM COG that can interpret/execute B code directly from HUB RAM or did you already do that as part of your integration into the shell? Sounds like 8 bit code with 24 bit data could work nicely with the P2 bytecode's execution mode if the extent of the opcode processing required can fit in a single COG.

Sign In or Register to comment.