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:202 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 from 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 provides a minimal framework, consisting of serial input and output, number conversion, text interpreter, command allocator plus a range of arithmetical, logical, stack and memory operations. From this collection of built in routines, elementary applications can be assembled. 

For example, if you were developing an application for a hex monitor, to view the contents of memory on screen in hex, edit it and save it back to memory you would assign characters for all the commands that you would need. 

A     set the Address    

C     Clear memory

D     Dump memory

E      Execute the routine

Alternatively if you were developing an application to control a CNC machine, plotter, 3D printer, robot etc you would probably use the X, Y, and Z characters that define the co-ordinates you wish the machine head to move.  The SIMPL interpreter can read these in one line at a time from an ascii text file to control the motion of the machine, or to draw graphics on a screen.  This is similar to the manner in which G-Code is used to control CNC machine tools, or Gerber files are used to control a photo plotter for pcb manufacturing.  These simple control tasks evolved in the 1960s, when processing power was very limited, so the application itself had to be kept non-complicated.  

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

marshallab wrote 11/06/2020 at 15:14 point

Hello from 2020...

I was very carried away by studying Txtmyze and your SIMPL. Google has mainly been publishing your blog since 2013 and sketches of the github. But yesterday I came across a hakkaday magazine. But I'm disappointed that Githab gives 404 error.

Is there a link to the current sources ?

  Are you sure? yes | no

monsonite wrote 11/06/2020 at 22:31 point

Hi the source code for SIMPL on the Suite-16 is here https://github.com/monsonite/Suite-16/blob/master/SIMPL_Suite16_2020_5.asm

Suite-16 is a novel cpu - and currently only exists as a simulation written in C code - but it runs about 20 million simulated instructions per second on a 600MHz Teensy 4.x

I hope I have given sufficient information for you to understand the concept and attraction of SIMPL - a tiny extensible language, that consists of not much more than a character identifier and a jump table contained in a loop.

It's the sort of thing that can be quickly implemented on any microcontroller - either in C code or in assembly language. I have written versions for AVR, MSP430, ARM and now "Suite-16". It's usually the first thing I implement on any new microcontroller project - it gives you a shell, and a framework on which to build upon.

I have purposefully tried to keep it down to below 1K bytes for quick and easy implementation.

I hope this encourages you to experiment with your own implementation.

  Are you sure? yes | no