Compiling BASIC with BASIC

44 views
Skip to first unread message

Diccon

unread,
Aug 13, 2009, 8:07:23 PM8/13/09
to OpenQM-OpenSource
This is a purely academic question. Martin, if you don't want to
respond that's fine.

How did you compile the BASIC written compiler, without the BASIC
compiler?

As the 2.6-6 release you last released stands, there is no way of
compiling the sourcecode for the BASIC compiler, without a fully
running and operational version of QM with a pre compile BASIC (and
more importantly BCOMP) program.

In theory it's impossible. Chicken and the eg style.

I know a true test of any new language is if you can write a good
compiler in its own language. Presumably there was another compiler to
start with. Is it now redundant? or was it deliberately excluded from
the GPL release, for some licensing reason.

Just curious really.
-Diccon

Martin Phillips

unread,
Aug 14, 2009, 4:26:57 AM8/14/09
to openqm-o...@googlegroups.com
Hi Diccon,

> How did you compile the BASIC written compiler, without the
> BASIC compiler?

In the very early days (and I do mean days, not months), there was an opcode
assembler. We wrote the Basic compiler in Basic but as comments in an
assember source module where each commented Basic line had the equivalent
opcode stream in assembler form. Once we had got to the point of having
something that looked hopeful, we mechanically extracted the Basic code and
got the compiler to compile itself. The point at which we declared this to
be successful was when the compiled compiler could compile itself and get
the same object code.

It sounds like a horrible process when written down but actually is was
quite a simple operation. There were odd occasions when we had to fall back
on a checkpoint and rework a change but it all came together quite quickly.
This whole chicken and egg situation leads to a few complications that exist
to this day. Note, for example, the comment in the SYSCOM.H include record
about the need to compile certain Basic modules in one run of the compiler
and in a specific order.

> As the 2.6-6 release you last released stands, there is no way of
> compiling the sourcecode for the BASIC compiler, without a fully
> running and operational version of QM with a pre compile BASIC
> (and more importantly BCOMP) program.

This is true in the commercial version too. When we migrate to a new
platform, we take a copy of the Basic code (and things like the VOC, etc)
from our master Windows system. (Actually we do this for every build. There
is only one Basic source/object and that is on the Windows system).

Exactly the same process works with the open source. This is partially why
we have maintained the corresponding commercial release on the website. You
can download it and either install in on a Linux box and build everything or
simply copy the global catalogue, VOC, etc.

The opcode assembler has long ceased to exist though I cannot see why we
would want it now.


Martin Phillips
Ladybridge Systems Ltd
17b Coldstream Lane, Hardingstone, Northampton, NN4 6DB
+44-(0)1604-709200

Diccon

unread,
Aug 14, 2009, 11:56:13 AM8/14/09
to OpenQM-OpenSource
Thanks you for explaining the evolution so clearly. I hadn't
considered it possible until Ashley pointed out the kind of technique
you described.

The only faults I can see with such a technique is cutting off the
branch your standing on when working on the compiler (and you break
something). But that is a short term problem, as you just grab a
previous working version of the compiler and begin again. I was well
aware that BASIC certainly required a number of additional BASIC
programs to work, (!parser etc) from experimentation. Had missed your
SYSCOM.H notes though. Thanks.

The reason I was looking into this was normally you don't distribute
binaries as part of the source code. Instead you indicate which
compiler to use to build from scratch. I sat scratching my head for a
while when I realised this seemed impossible.

Since QM is a virtual machine system there are not the normal issues
of architecture differences. So I can't see much wrong with the way
its done.
Was just curious if about the official way you guys do it.

Thanks
-Diccon

On 14 Aug, 09:26, "Martin Phillips" <martinphill...@ladybridge.com>
wrote:
Reply all
Reply to author
Forward
0 new messages