SIMPL as an Instruction Set

A project log for SIMPL

Serial Interpreted Minimal Programming Language for exploring microcontrollers & new cpu architectures

monsonitemonsonite 01/16/2021 at 22:260 Comments

As stated earlier, SIMPL will run on a microcontroller or other processor device using an interpreter which forms the basis of a Virtual Machine, which I have chosen to call a SIMPL Machine.

The SIMPL Machine uses printable ascii characters to create a concise, human readable language.

For convenience the printable ascii are divided into 4 sub-sets:

Numbers  0-9  A numerical string will be converted to a 16-bit integer in the range 0-65535

Lowercase  a-z   Lowercase alpha characters are generally used to call ROM based functions for printing and control of I/O

Uppercase A-Z  Uppercase alpha characters are generally used for user defined commands, variables and registers

Symbols     + - * /  etc.  These 33 symbols are used to define the primitive instructions and structures for the SIMPL Machine language.

It is the symbol and punctuation characters which will be used to define the Instruction Set, along the lines of the MISC machines developed by CH Ting and CH Moore.

The SIMPL instruction set is concise because each command is a single ascii character. 

It takes the form of human readable shorthand which removes the need to memorise hex codes or processor specific instruction mnemonics. Traditional assembly language frequently uses mnemonics that are 3 characters long,  ADD, SUB, AND XOR.

Note: Although each instruction is represented by a single character. If however a more traditional listing were required it would be an easy programming exercise to substitute the character for a more conventional mnemonic. 

SIMPL replaces these with single characters which minimises the text and vastly simplifies the overheads of parsing multi character text.

Source code is much more compact than traditional assembly language.  It can be loaded directly into RAM - either by typing or using the Send File feature of most terminal emulator programs.

SIMPL could become a lingua franca for microcontrollers or microprocessors.

Provided that the SIMPL VM was coded into the target cpu, whether AVR, ARM, Z80 or 6502 etc. the same SIMPL source code will run on any of the machines.  It forms a universal assemby language and could be used to replace cpu specific mnemonics and assembly listings.

Instruction Primitives.

These are allocated to the 33 printable ascii symbols.  They provide arithmetic, logic and comparison operations as well as memory and register access, looping and program flow control. 

Using the concept of a Minimal Instruction Set Computer  (MISC) a complete machine can be created with fewer than 32 primitive instructions. 

There have been several historical machines that illustrate this concept - such as the PDP-8, the MSP430, Marcel van Kervinck's Gigatron TTL computer and several of the Forth cpus by Charles H. Moore. 

The SIMPL VM is based on a stack machine with a 4 level circular stack. Most operations operate on the top 2 elements of the stack.

Arithmetical and Logical Operations 

+       ADD

-        SUB

*        MUL (Left Shift)

/        DIV   (Right Shift)

&       AND

|         OR

^        XOR

~        NOT

`         INCREMENT

Memory Access

@       FETCH

!         STORE

Stack Manipulation

"         DUP

'          DROP

$         SWAP

%        OVER

           SPACE - used to PUSH consecutive numbers onto the stack

Conditional / Comparison 

<         LESS

>         GREATER

=         EQUAL

Input / Output



_       TEXT STRING 

#       LITERAL

\        COMMENT

The remainder of the symbol instructions are used to control program flow and create structures

{        BEGIN LOOP

}        END LOOP

[        BEGIN CASE

]        END CASE

(        BEGIN ARRAY

)        END ARRAY