I haven't written much in a while because I was getting stuck into doing things with the Inferno C compilers and wanted to finish that before writing something else. Unfortunately, things didn't come to an interesting conclusion so there wasn't much to say about it, and that's not really motivating to write about.
While using the Thumb toolchain to build simple bare-metal programs for a microcontroller, I decided to see if a cut-down build of Inferno would build and fit in the available flash memory. It was possible to build a kernel and copy it into the reasonably large amount (1024 K) of flash memory. The system would even boot as far as running the initial Limbo process, but that's where things became complicated.
The tricky part is handling context switches. Inferno ports need to implement two functions: setlabel saves the stack pointer and program counter, and gotolabel restores them to resume execution of a process, or to switch to a different process. This is pretty straightforward. However, when the system timer is used to preempt processes, a lot more work needs to be done to save registers, change processor modes and return to normal execution. The regular 32-bit ARM ports switch from IRQ mode to SVC (supervisor) mode during this operation. However, mode switches like this aren't possible (it seems) when running Thumb-2 code on Cortex-M4 series MCUs, and there's no 32-bit mode to use instead.
As a result, it's not possible to directly translate the 32-bit code, and I'm not sure what limitations I might be encountering when my interpretation of it fails to work. It could just be that I run out of stack space and corrupt other data or stacks.