Email or username:

Password:

Forgot your password?
lawless polymorph

mini-announcement: I've decided to publish Yotta.

Yotta is a forth-like language with a very small core. In the beginning, all you can do is:

- emit machine code,
- emit machine code that emits machine code,
- define new words ... that emit machine code

With just those primitives we define an x86-64 assembler, and from there we use that assembler to define most of a forth.

Check it out: github.com/typeswitch-dev/yott

2 comments
lawless polymorph

In Yotta there are only three primitives:

$XX emits the byte XX (in hex)
^XX emits machine code that emits XX
: A defines the word A

From there, the first thing we need to do is define semicolon (;) which emits the RET instruction. Semicolon is used to end word definitions. We use semicolon to end its own definition.

This is the preamble, the first bit of Yotta code that the Yotta interpreter/compiler runs. Besides semicolon, we're also defining line and block comments with \ and ( ).

In Yotta there are only three primitives:

$XX emits the byte XX (in hex)
^XX emits machine code that emits XX
: A defines the word A

From there, the first thing we need to do is define semicolon (;) which emits the RET instruction. Semicolon is used to end word definitions. We use semicolon to end its own definition.

lawless polymorph

After the preamble, there is an x86-64 assembler, written in Yotta. The assembler makes it much easier to work with machine code, as you might expect.

However the assembler is a bit quirky, because it uses a syntax that reflects the structure of the machine code. It's neither intel syntax nor at&t syntax, but a secret third thing.

I won't get into the assembler details, but let me show you how it's used to build a forth:

Go Up