Skip to content

Byte Code

Joachim Wester edited this page May 30, 2016 · 3 revisions

The Addie VM

Addie is an interpreted language for maximum portability. To be fast and efficient, we have chosen a register based virtual machine architecture.

Our fixed size bytecode instruction

Bytecode instructions are fixed in size (32 bits).

The operation layout

The OP code uses 8 bits. The structure of the remaining 24 bits depend on the OP code at hand.

31-24 23-16 15-8 7-0
A B C OP
A2 C OP
A3 OP

The core instruction set

As Addie is interpreted, we will try to use as many high level OPs as possible. To make comprehension simpler, we divide the OP codes into the core set and the extended set. The OP prefix and OP suffix are for mnemonics only, the two are baked together into a single byte.

OP prefix OP suffix Description
call noarg
fixarg
vararg
Call a subroutine. The first operand is the return register. The second is the function to call. The following registers are the arguments.
deref Translate a unresolved symbol to a value
ret Return from a subroutine
jmp-if-true r0
rx
Conditional jump

The extended instruction set

OP prefix OP suffix Description
s-call noarg
fixarg
vararg
Call a subroutine. Merges a deref and a call operation. Works like call, but with the second operand being an unresolved symbol.

Clone this wiki locally