Opcode | Assembler syntax | Description |
---|---|---|
000 | brk | Stop machine |
1xx | ld MemoryAddress | Load value from address, push to stack |
2xx | st MemoryAddress | Pop value from stack, store at address |
4xx | jsr MemoryAddress | Push program counter to stack, jump to address |
5xx | jmp MemoryAddress | Jump to address |
6xx | jz MemoryAddress | Jump to address if stack top is zero |
7xx | jlz MemoryAddress | Jump to address if stack top is negative |
8xx | io Device:Port | Send stack top to device |
800 | out | Print stack top as number |
801 | printch | Print stack top as ASCII character |
301 | dup | Copy stack top |
302 | drop | Remove stack top |
303 | swap | Swap two top stack values |
304 | ovr | Push to stack value before top |
310 | rnd | Push random number to stack |
311 | add | Pop 2 numbers, add, push result to stack |
312 | sub | Pop 2 numbers, subtract, push result to stack |
313 | and | Pop 2 numbers, apply logical AND, push result to stack |
314 | or | Pop 2 numbers, apply logical OR, push result to stack |
315 | xor | Pop 2 numbers, apply logical XOR, push result to stack |
316 | rsh | Pop 2 numbers, apply right bitshift, push result to stack |
317 | lsh | Pop 2 numbers, apply left bitshift, push result to stack |
318 | inc | Add 1 to stack top |
319 | dec | Subtract 1 from stack top |
321 | neg | Change stack top sign |
322 | inv | Invert stack top bits |
330 | ji | Pop address from stack, jump to address |
331 | ldr | Pop address from stack, load value from address |
332 | str | Pop value and address from stack, write value to address |
Experimental instructions
Opcode | Assembler syntax | Description |
---|---|---|
Dxx | rld | Load value from address relative to BP |
Exx | rst | Store value at address relative to BP |
380 | enter | Save base pointer, set it to current stack pointer |
381 | leave | Restore base pointer |
Pseudoblock is defined by single {
and }
on lines.
Inside pseudoblock you can use =begin
and =end
labels that represent nearest braces
Example
ld @zero st @counter { ld @limit ld @counter sub jz =end jlz =end ; leave pseudoblock if counter >= limit ... ld @counter inc st @counter ; increment counter jmp =begin ; next iteration }
ld 102 jmp 50
Defining label
var: data 100 label1: brk
Referencing label
ld @var jmp @label1
jmp =begin jmp =end
Numeric data
var1: data 128
String
str1: string Test
Pointer
ptr1: data @var1
ld @strptr ; load string address { dup jsr @iload ; call subroutine for indirect load jz =end ; if zero jump outside of brackets block (=end) printch drop inc jmp =begin ; jump to block start } drop ; clean stack drop brk str: string Hello data 32 string world! data 0 strptr: data @str load_op: data 256 iload: swap ld @load_op add ; making ld instruction with passed address st @iload2 ; indirect loading via self-modifying code iload2: brk swap ji