Another update: I have worked quite a bit on my compiler
the last couple of days and have managed to make it produce the same
code as those in the binaries (compared the intermediate code by eye).
There were a few mistakes, the files have been updated.
I removed some features that I figured were not in ken's original
compiler and most importantly changed it to generate RPN code directly
instead of parsing an expression into a tree and generating code from
that, which ken confirmed was how it worked.
I'm still not entirely happy with the result (the build() function seems
a bit kludgy), but at least it seems to produce something accurate.
Unfortunately I have no idea what the intermediate would have looked
like, so the output of this is purely my fantasy.
I will also have to adjust my take on ba now due to the changes.
For anyone interested, this is my WIP version of bc.b:
https://gist.github.com/aap/6df9b4c53c63592437d97dadab533649
aap
On 17/06/23, Angelo Papenhoff wrote:
Update: I'm now done with the first pass of
this.
I reversed all the programs and successfully ran them through my
compiler (i haven't assembled or linked anything though).
http://squoze.net/B/programs/
To check for correctness, the files should of course be compiled,
assembled and linked again. Unfortunately my compiler currently
does not generate quite the same code as the original one. I will
have to work on this.
Most importantly & and | are only bitwise operators in the version
of B that compiled these programs, but some other differences (like
the fixup chain and the way strings are stored) exist too.
It would be nice to have a fully working B system on v1/v2 UNIX again,
with everything built from source, we can even reconstruct different
versions of the runtime (and perhaps standard library). So far the
PDP-11 version of my B system has only run on v6 and 2.11BSD.
best,
aap
On 14/06/23, Angelo Papenhoff wrote:
> I will hopefully continue with this in the next time (if, goto, mail and
> glob are left).