Compiling the H2D2 programming language for AVR micros

I've been trying to make my latest attempt at writing a programming language (which I'm currently calling H2D2) as portable as possible. So I decided to try and recompile it for AVR microprocessors using WinAVR. It worked fine with just some very minor tweaks (and the odd bug fix). So here's a simple H2D2 program running on a (simulated) AVR microprocessor:

Specifically, it's a simulated ATmega128 running inside VMLAB. The program just writes out a series of ASCII characters in a loop, like this:

loop
  loop (c=65)
    print c
  repeat (c=c+1 if c<91)
repeat

There have also been some more improvements to the syntax, where I'm continuing to draw on DALIS for inspiration. This time round I seem to be making more use of brackets. More things are coming out looking like C functions, which is why we have loop() and repeat(). I'll probably enforce brackets with if() as well I expect.

Currently, the microprocessor is parsing the source code, generating the syntax tree (i.e. compiling to H2D2 bytecode) and then running it in the H2D2 Virtual Machine. It might be better to just have the VM on a microprocessor and somehow get the bytecode onto the device pre-compiled.

But at least this microprocessor example demonstrates that my C code is reasonably portable, hopefully I can keep it like this. In reality running a Virtual Machine on top of a small microprocessor might not be very practical, but I'm just trying to make sure that my code can target other devices really...

I'm tempted to try running this code on my Fez Panda II by means of RLP, which should allow me to run H2D2 as native ARM code (being called from inside the .Net Micro Framework), that might have to be tried out.

Improved annoyatron

I think that it's good to keep your hand in with some plain old C programming once in a while.  So I ocasionally mess around with microprocessors. I've been working on an improved annoyatron, with my version it will pretend to be a mobile phone - by playing a simple ringtone. This is what it currently looks like:

annoyatron 2.0

 I've used an AVR ATmega168 microprocessor, which is over spec, but I had a couple of them lying around.  In fact all of the other components except for the button cell battery and holder were things that I had sitting around.  What tends to happen is that before I throw anything away, I take it to bits to see if I can remove anything.  Even a salvaged switch can be useful one day.  And it's fun to take stuff apart :-)

So ... what I'll try to do is post more about this - what development tools I've used and what I have discovered along the way.  I'll be sure to refer back to it if nobody else does.