Fork me on GitHub

Demo

Examples:

Registers

Name Size General Description
A 8 bit Yes
B 8 bit Yes
D 16 bit Yes concatenation of A and B
X 16 bit Yes
Y 16 bit Yes
IP 16 bit No used for instruction pointer
FLAG 8 bit No store the flag of comparison and arithmetical operation

Instructions

OpCode(decimal) Mnemonic Operand Scope Example Description
1 LDA immediate b32 LDA #100 load value into register A
2 LDX immediate b32 LDX #100 load value into register X
3 STA, X b32 store value in register A into memory location specified by register X
4 END label b32 END #Start terminate the program
5 CMPA immediate b32 CMPA #100 compares value in register A, and sets register FLAG
6 CMPB immediate b32 CMPB #100 compares value in register B, and sets register FLAG
7 CMPX immediate b32 CMPX #100 compares value in register X, and sets register FLAG
8 CMPY immediate b32 CMPY #100 compares value in register Y, and sets register FLAG
9 CMPD immediate b32 CMPD #100 compares value in register D, and sets register FLAG
10 JMP label b32 JMP #Loop jump to the address of the label
11 JEQ label b32 JEQ #Loop jump to the address of the label only if the EQ is set on the register FLAG
12 JNE label b32 JNE #Loop jump to the address of the label only if the NE is set on the register FLAG
13 JGT label b32 JGT #Loop jump to the address of the label only if the GT is set on the register FLAG
14 JLT label b32 JLT #Loop jump to the address of the label only if the LT is set on the register FLAG
15 INCA b32 add one to the value in register A
16 INCB b32 add one to the value in register B
17 INCX b32 add one to the value in register X
18 INCY b32 add one to the value in register Y
19 INCD b32 add one to the value in register D
20 DECA b32 subtract one from the value in register A
21 DECB b32 subtract one from the value in register B
22 DECX b32 subtract one from the value in register X
23 DECY b32 subtract one from the value in register Y
24 DECD b32 subtract one from the value in register D
25 ROLA b32 rotate the value in register A to the left
26 ROLB b32 rotate the value in register B to the left
27 RORA b32 rotate the value in register A to the right
28 RORB b32 rotate the value in register B to the right
29 ADCA b32 add one to the value of register A only if the CARRY is set on the register FLAG
30 ADCB b32 add one to the value of register B only if the CARRY is set on the register FLAG
31 ADDA immediate b32 ADDA #100 add the value to register A
32 ADDB immediate b32 ADDB #100 add the value to register B
33 ADDAB b32 add the values of register A and register B, and then store the result into register D
34 LDB immediate starterVM LDB #100 load value into register B
35 LDY immediate starterVM LDY #100 load value into register Y
36 INT immediate starterVM INT #1 trigger one interruption
37 STB, X starterVM store value in register B into memory location specified by register X
38 LDX address starterVM LDX [#100] load value stored at memory address into register X
39 STY, X starterVM store value in register Y into memory location specified by register X
40 LDY address starterVM LDY [#100] load value stored at memory address into register Y
41 LDA address starterVM LDA [#100] load value stored at memory address into register A

Interrupts

ID Name input registers output registers Description
1 random X, Y D generate a pseudo-random integer, and set it into D register.
2 sleep X sleep a while before executing next instruction
3 buff add a value into input buffer
4 buff B get and remove a value from input buffer