SIMPL - a Tiny Interactive Language for Microcontrollers or Experimental CPUs.
SIMPL is a symbolic language for programming microcontrollers based on printable ascii characters.
Each character, read in turn from RAM is interpreted and forms either an instruction, or a jump to an executable block of code, running on a virtual machine. The virtual machine is assumed to have a 16-bit wordsize and a 64Kbyte address space.
For example + will perform a 16-bit addition on the top two elements of the stack, whereas p will take the top element of the stack and print it to the terminal as a 16-bit decimal number.
In each case, the character is used in a look-up table or switch-case structure, to generate a unique jump to a block of code in ROM, which performs the command action.
Characters can be chosen by the programmer to have a strong mnemonic value, such as + for ADD and p for PRINT. Reducing these instructions to single characters makes the language very concise.
Thus SIMPL provides a shorthand means to communicate with a microcontroller or other computing device using an interactive command shell. This allows control the microcontroller and its harware peripherals using short snippets of code, or "microscripts" typed at the keyboard, or sent as a text file from a terminal emulator.
The interpreter can be pointed to any location in memory to begin parsing SIMPL code from there. Any location in memory containing a valid, printable ascii character (ascii $20 to $7E) will result in a jump to a legitimate code block, or trapped as an unused command.
In the case of commands typed from the keyboard, this memory will be an array in RAM that forms the Text Input Buffer (TIB). The code in the TIB will be executed immediately when the parser receives a carriage return character. This is called Immediate Mode.
The interpreter may also be pointed to a location in RAM containing the User's program. It will begin execution there and will continue until it finds a non-printable ascii character. This could be a carriage return or a null character. This is called Run Mode. A user program might be very short, or it might involve many nested loops - for example printing out a hex-dump of a block of memory.
A third mode of operation is possible, where SIMPL code is executed from ROM. This allows commonly used routines to be stored permanently in ROM. Again, the SIMPL code is likely to be more concise than the native assembly language of the microcontroller, as a single byte character represents an instruction or even a complete routine.
A SIMPL Example
SIMPL consists of short snippets of code, which I will call "microscripts".
A microscript consists of a series of commands, normally in lowercase alpha ascii characters, with numerical parameters to define the behaviour of the commands.
For example, to flash a LED on an Arduino, the microscript would be as follows:
13d10{h100ml100m} - this gives 10 short 100mS flashes of the LED on pin 13
We cam modify this example easily - to play a tone on a small speaker connected to a digital pin. In this case we would use the microseconds delay command u contained within a loop.
8d1000{h500ul500u} - this gives a 1kHz tone of 1 second duration to a small speaker connected to Digital Pin 8.
The microscripts give a great amount of flexibility, and as they are directly executed out of RAM, they can be edited "on the fly" and pasted back into the command line, to bring about an immediate change in function.
SIMPL was originally designed to provide an easy means to control the common microcontroller peripherals including UART, digital inputs and outputs, ADC, SPI, I2C etc.
It provides great flexibilty and can be adapted and extended to a wide range of applications.
The SIMPL Machine
SIMPL forms an instruction set for a virtual machine, running on a microcontroller or any other processing device. I will refer to this VM as the...
Why using simply language if You have mruby?