Skip to content

Instruction Set

Cristian edited this page Oct 5, 2023 · 4 revisions

General

virtualice <version>        ; set magic number and version

halt
rest                        ; no operation

Stack

const.[b|w|d|q] <value>     ; push a constant (byte, word, double, quad)
const.[0|1|f|t|h|l]         ; push 0, 1, false, true, high, low

swap                        ; swaps the top two stack values

drop                        ; drop the top of the stack
drop.n  <n>                 ; drop the top n elements of the stack (max 255)
clone                       ; clone the top of the stack
clone.n <n>                 ; clone the top of the stack n times   (max 255)

Arithmetics

[add|sub|mul|div].[n|i|r|c] ; nat = int in some cases
[mod|pow].[n|i|r]
[inc|dec].[n|i|r]           ; nat = int here

project                     ; project complex into real and imaginary parts
project.[r|i]               ; project complex's real or imaginary part
magnitude                   ; magnitude of a complex number
conjugate                   ; complex conjugate
combine                     ; combine 2 floating numbers into a complex

convert.[n2r|i2r|r2i]       ; convert-cast between types

Bitwise and Logical Operations

mask.[b|w|d|q]              ; (byte / boolean, word, dword, qword)
bit.[g|s|r] <n>             ; (get, set, reset) nth bit
nibble.[l|h]                ; get (low, high) nibble
nibble.s                    ; swap nibbles of a byte
[buffer|and|or|not|nor|nand|xor|xnor|xand]
[invert|complement|reverse] ; invert, complement, reverse
[rotate|shift].[r|l] <n>    ; shift / rotate (right, left) by n bits

Jumps and Comparisons:

jump [label]                        ; uncoditional jump
jump.[1|0|z|nz|t|f|e|ne]    [label] ; if (one, zero, not zero, true, false)
jump.[g|ge|l|le].[n|i|r]    [label] ; if condition is met
compare.[g|ge|l|le].[n|i|r] [label] ; push result of comparison

Functions, Kernel, Lambda Calls

address [address]           ; push (32bit) address (of function, lable or data)

call    [function]          ; call a normal function
call.k  [function]          ; call to kernel
call.l                      ; indirect lambda call

arity   <n>                 ; sets the parameters to n

return                      ; returns a value
return.v                    ; returns void

Global and Local Variables, Function Parameters

global.r  <index>           ; read  a global variable
global.w  <index>           ; write a global variable

local.r   <index>           ; read  a local variable
local.w   <index>           ; write a local variable

param.r   <index>           ; read  a function parameter
param.w   <index>           ; write a function parameter

Memory Load, Store, Pointers

load.[b|w|d|q]  [address]   ; load  a value from memory
store.[b|w|d|q] [address]   ; store a value  in  memory