Project: Some aid for low level programmer
Francois-Rene Rideau
Francois-Rene Rideau <fare@tunes.org>
Sun, 2 Jun 2002 03:11:25 +0200
Dear Peter,
sorry for the late reply.
Yours is the compembler approach, developed notably
by Rick Hohensee <rickh@capaccess.org> with osimplay.
building a language over an open code generator written in (yuck) bash,
from binary output up to a structured low-level language.
ftp://ftp.gwdg.de/pub/cLIeNUX/interim/osimplay.tgz
Many FORTH also use a similar technique for code generation
(not surprisingly, rickh is a forther).
If you're into C (yuck), you should also take a look at ccg,
reusing the runtime of which lightning was written.
I can't find it on Ian Piumarta's page anymore,
but a backup is available at basile's:
http://perso.wanadoo.fr/starynkevitch/basile/ccg-1.1.tar.gz
If you're to do it in Lisp for TUNES, then you're most welcome.
> So if you use Lisp which has buildin self modification, you can self
> modify the virtual machine.
Actually, Lisp only has "self-modification" at the source-compiler level,
through reader-macros and macros. Lisp standardizes a few introspection
utilities, but any self-modification beyond that is very system-dependent,
and not something Lisp vendors insist upon.
One issue is that self-modification can easily lead to instability
and lots of compatibility and non-modularity issues,
so you mostly want to do it inside controlled virtual machines.
However, since there is no first-class such virtual machines in Lisp,
you just open a completely new Lisp environment using an underlying OS'es
foreign facilities. Forthers do something similar at times:
reloading an environment with different defining words for debugging.
> And for VMs: My system is in no way virtual.
Sure. Virtual systems are a step afterwards.
They must be layered upon a generator for the physical machine.
> As I my original intention when I came up with this concept was to write
> a lisp OS I think I understand parts of your OS approach.
> But my system is more like the CLib except that it is not a lib and
> is on Asm similar stuff (hardware)
If we can share some efforts, that's all the better.
> a) On top of an OS, steps of compilation
> or b) in a bootloader/kernel creating code at boot time?
Ian Piumarta has written a scheme system that creates most of its code
at initialization time.
>> More elaborate macros, that might require more contextual information
> This is ALL in my extensions. This means you have that kind of system
> specification stuff at hand that you normally only think theoretically
> of. Like CPU type, register size, which kind endian, infos about the
> hard disk, bit access,etc
Yes. Ultimately, there should be a rather complete specification
of the behaviour of the underlying low-level machine.
But we can't escape starting with rather imperative ways of dealing
with this low-level behaviour. When the system is bootstrapped,
you can get more and more declarative about all these bits.
Sometimes, it is better to be declarative sooner
about some of this information. Only experience may tell
what is the right pace for building more declarativeness.
Jacques Pitrat, who's been building reflective systems for four decades,
says he still has no universal recipe for deciding how long bootstrap
steps should be to go from the initial metasystem to a declarative system,
through more or less imperative intermediate versions.
> If you for example would use Common Lisp it would be supported.
Yup, I think I'll take CL for a starting metasystem.
> Did I get that right: A parsergenerator which build a parsergenrator?
Hum. More of a code generator that builds a code-generating system.
> Are you busy because you went to the MLRISC or RISCML site?
The MLRISC docs is in my reading list, as so will be its sources,
but have a hunch that I will still want to do something different in Lisp,
starting with something much like what you're proposing.
Ok, so now, let's pick a target (obvious choices: i386, ppc, arm),
and write a compembler for it in Common Lisp...
[ François-René ÐVB Rideau | Reflection&Cybernethics | http://fare.tunes.org ]
[ TUNES project for a Free Reflective Computing System | http://tunes.org ]
If Java had true garbage collection, most programs would delete themselves
upon execution. -- Robert Sewell