MINT - a minimal interpreted language

Using, learning, programming and modding the Gigatron and anything related.
Forum rules
Be nice. No drama.
Post Reply
monsonite
Posts: 101
Joined: 17 May 2018, 07:17

MINT - a minimal interpreted language

Post by monsonite »

Back in the mid 1970s when early home computers were very limited on memory, there were a number of attempts to create high level languages, that would fit within the tiny available memory space. Tiny BASIC is probably the best known of these and indeed it was one of the first interpreted languages available on the Gigatron. I believe that Marcel ported it and got it running in about a week!

In the last few months, I have been working on a tiny interpreted language, called MINT. It is a stack based language, and could be likened to a very minimal implementation of Forth. A full version of Forth usually uses about 6K or 8K bytes of memory, but MINT has been engineered to fit into 1K bytes.

MINT is essentially a 16-bit virtual machine, designed to run on an 8-bit cpu. It has about 30 instructions, coded into ROM, which provide the basic instructions like ADD, SUB, AND, OR, XOR. These instructions are accessed using a single byte instruction code generated using a look up table.

If this sounds familiar, it is exactly what vCPU does. In pages 03 and 04 of the Gigatron ROM, there are approximately 37 primitive instructions coded, all performing 16-bit operations, such as ADD, SUB, AND, OR, XOR. The 16-bit ADD, for example, is 28 native assembly instructions long, and takes 4.48uS to execute on a standard 6.25MHz Gigatron.

Each instruction is referenced by the 8-bit address that it's associated routine commences on page 03 of the ROM. For other instructions that overspill onto Page 04, there is a "trampoline" jump that allows them to be accessed.

So vCPU code is a series of 8-bit opcodes, that are fixed by the contents of the ROM, and have been ever since the first version of the ROM.

These opcodes are arbitrary, they are just jump adressesses into a page of assembly language. What MINT does, is it converts these arbitrary addresses into printable ascii characters, that are memorable, logical and still only 1 byte long.

So for example, a 16-bit ADD operation translates to the familiar + symbol. Subtract, Multiply and Division are the equally familiar - * and /.

There are 33 printable ascii punctuation characters, and these form the bulk of the primitives.

The language is not only interpreted but it executes immediately without compilation.

if you want to add two numbers, you just type the following at the keyboard:

123 456 + .

and the machine responds with

00579
OK

So far I have written MINT for the Z80 and there is a 6502 version in progress. Because the vCPU has already done a lot of the "heavy lifting" for the Gigatron, I think a port will be relatively straight forwards. It will open up the power of the vCPU to a simple interpreted language, typed at the keyboard
monsonite
Posts: 101
Joined: 17 May 2018, 07:17

Re: MINT - a minimal interpreted language

Post by monsonite »

More details of MINT are on my Github repository:

https://github.com/monsonite/MINT
at67
Site Admin
Posts: 647
Joined: 14 May 2018, 08:29

Re: MINT - a minimal interpreted language

Post by at67 »

This looks very cool, like a modern version of CHIP8, that kind of ethos?
monsonite
Posts: 101
Joined: 17 May 2018, 07:17

Re: MINT - a minimal interpreted language

Post by monsonite »

Yes, a bytecode language, with a similar ethos to CHIP 8, packaged into 1K bytes of memory.

The symbols chosen to represent the instructions are all chosen to have mnemonic value, so that the source code is human readable text.

It shares a lot in common with Forth, but lacks the dictionary, and the requirement to do parsing of multi-character words.

User commands are allocated to uppercase letters, and user variables assigned to lowercase letters.
Post Reply