A Hugs bytecode interpreter

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Mon, 2 Apr 2001 11:31:57 +0100


> There is nhc98, of course, but it is somewhat bulky for the purposes I
> have in mind.  I am looking for something small that would compile to
> 16-bit code that would run in 64K code + 64K data.

It's a shame that nhc98 doesn't fit your requirements, since it is
specifically designed for creating small-memory-footprint programs.
But as far as I know, Hugs is the only Haskell system that can produce
16-bit code.

> So my question is, has anyone tried to rearrange the components of
> Hugs into a bytecode compiler plus runtime?

The predecessor of Hugs was Gofer, which was supplied with a variant
called Gofcc that produced standalone bytecodes, just as you desire.
Gofer was very like Haskell 1.2.  It is still available by FTP:

    http://www.cse.ogi.edu/~mpj/goferarc/index.html

Many years ago for my PhD work, I modified Gofer/Gofcc to create
standalone programs to run on an embedded system.  The resulting a.out
program had to be encoded into S-records and downloaded to the board
via a serial cable.  Back then, I was targeting a 32-bit processor
(M68000), but Gofer was equally capable of producing 16-bit code.
As I recall, my most complex example (a liftshaft control program,
attached to a real physical liftshaft made of mecchano) probably needed
around 250Kb of memory in total (code + heap + stack), although the
board was fitted with a generous 768Kb.

My modified version of Gofer/Gofcc is available here:

    ftp://ftp.cs.york.ac.uk/pub/malcolm/goferp.tar.Z

It includes several other features that might be of use to you if you
are writing embedded systems:  a realtime garbage collector, concurrent
processes, device control and interrupts, and a heap-profiler
(producer/construction/retainer variants) to help you minimise your
runtime space usage.  Some papers describing the various features
are available from my homepage:

    http://www-users.cs.york.ac.uk/~malcolm/

Regards,
    Malcolm