Close

SIMPL Revisited

A project log for Suite-16

Suite-16 is a 16-bit cpu built entirely from TTL. It is a personal exploration of how hardware and software interact.

monsonitemonsonite 01/21/2020 at 20:200 Comments

Back in late October, just as I was starting to hand-code some assembly routines for Suite-16, I considered porting my bytecode interpreter SIMPL across from MSP430 assembly language to that of the Suite-16.

Unfortunately at that time, the instruction set was very much in a state of flux and still evolving, and hand assembly was somewhat time-consuming. Revisiting this task now that we have an assembler and a hexloader in our toolchain armoury makes the job so much easier, and I have transcribed the SIMPL framework in a long afternoon sprint of about 6 hours coding. As well as the code, it is highly commented, thus documenting the workings of the SIMPL interpreter as I went along.

What is SIMPL?  At it's most basic level it is an interpreter consisting of a switch statement contained in a loop. After all - that is how most simple processors and virtual machines are simulated. To make the job easier in assembly language - the switch statement is replaced with a jump table, with one 16-bit entry for each of the 96 printable ascii characters.  In essence, when a command character is read from the input buffer, it is used to index into the jump table and pick up a 16-bit address for the code-block associated with that command.

SIMPL is stack based, so numbers are put onto  the stack and operated on there.  It is a tiny-Forth-like utility language without the complexity of the dictionary and text string matching that is needed in a full-blown Forth.

So the commands include familiar mathematical and logical symbols such as  + - * and  /, which obviously relate to arithmetical operations.

Then there are the stack operations  - familiar to those using Forth, such as DUP, DROP, SWAP and OVER. In addition there are  commands associated with decimal and hexadecimal number entry and also output routines to a serial terminal for decimal, hexadecimal and hex-dump formats.

The user has 26 commands available - that can be user defined and customised. These are represented by the uppercase characters A to Z.  The language is extensible just by assigning a user command to a snippet of instructions.

SIMPL is very compact. The minimal interpreter framework with all the input and output utility routines is under 256 program words. The Jump table is a further 96 program words. To this you must add the action routines associated with all of the potential 96 commands - but these are often very small - each only a few instructions long.  

SIMPL is easy to tailor to your own application, as rudimentary or complex as you wish. If you want commands for floating point math routines then these can be added.  Generally I use it for exercising new hardware - or in this case thrashing out any discrepencies in the Suite-16 instruction set.

I have placed the SIMPL framework in my github repository here:  - it is as yet untried and probably buggy - but gives an idea what can be done with a couple of hundred words of assembly language.

Discussions