Module opcodes

Source

Constantsยง

ADD
ADD A B - set R(A) = R(A) + R(B)
APND
APND A B C - R(A) = append lists R(B)..R(C) (R(B) and R(C) are inclusive)
BMOV
CALL
CALL A B C - Call fn R(A) with B args with R(C) as first reg/param
CALLG
CALLG A B C - Call fn G[A] with B args with R(C) as first reg/param
CALLM
CALLM A B - Call current fn with B args with R(C) as first reg/param
CAR
CAR A B - R(A) = car(R(B))
CCC
CCC A B - call with continuation, R(A) must be a lambda that takes one arg (the continuation) R(B) is the first reg for the call
CDR
CDR A B - R(A) = cdr(R(B))
CLOSE
CLR
CLR A - Clear the collection in R(A)
CLRREG
CONS
CONS A B C - R(A) = conscell(R(B), R(C))
CONST
CONS_BASE ๐Ÿ”’
Cons cells
COPY
DEC
DEC A B - Decrement the integer in R(A) by B
DEF
DEFV
DFR
DFR A - Add a lambda, R(A) to the deferred list.
DFRPOP
DFRPOP - Pop and call the last deferred lambda.
DIV
DIV A B - set R(A) = R(A) / R(B)
EQ
EQ A B C - R[A] is #t if objects in R[B] - R[C] (inclusive) are the same objects
EQUAL
EQUAL A B C - R[A] is #t if objects in R[B] - R[C] (inclusive) are the same objects, values or containers with equal values (must be the same container type)
ERR
ERR A B - raise error with key R(A) (must be keyword) and value R(B)
FLOW_BASE ๐Ÿ”’
Flow control
FRZ
GET
HALT
INC
INC A B - Increment the integer in R(A) by B
ISERR
ISERR A B - R(A) is #t if R(B) is an error type, #f otherwise
ISOK
ISOK A B - R(A) is #f if R(B) is an error type, #t otherwise
JMP
Jumps, all jumps use a signed 24 bit OFFSET (high bit is sign and next 23 are integer). This means all jumps are forward or back (negative target). JMP OFFSET - Jump to IP + OFFSET
JMPEQ
JMPEQ A B OFFSET - compare A and B and jump to IP + OFFSET if they are equal
JMPF
JMPF A OFFSET - Jump to current IP + OFFSET if R(A) is falsy (nil or false)
JMPGT
JMPGT A B OFFSET - compare A and B and jump to IP + OFFSET if R(A) > R(B)
JMPLT
JMPLT A B OFFSET - compare A and B and jump to IP + OFFSET if R(A) < R(B)
JMPNU
JMPNU A OFFSET - Jump to current IP + OFFSET if R(A) is NOT undefined
JMPRNU
JMPRNU A B OFFSET - Jump to current IP + OFFSET if any in R(A)..R(A+B) is NOT undefined
JMPRU
JMPRU A B OFFSET - Jump to current IP + OFFSET if any in R(A)..R(A+B) is undefined
JMPT
JMPT A OFFSET - Jump to current IP + OFFSET if R(A) is truthy (not (nil or false))
JMPU
JMPU A OFFSET - Jump to current IP + OFFSET if R(A) is undefined
LDSC
LDSCR
LEN
LEN A B - R(A) = length of data in R(B)
LIST
LIST A B C - R(A) = list(elements R(B)..R(C)) (R(B) and R(C) are inclusive)
MAPMK
MAPMK A B C - R(A) = map(elements R(B)..R(C)) (R(B) inclusive, R(C) exclusive), alternating key, val pairs
MATH_BASE ๐Ÿ”’
MAX_OP_CODE
MDSC
MKERR
MKERR A B C - R(A) = error with key R(B) (must be keyword) and value R(C)
MOV
MOVI
MOVII
MUL
MUL A B - set R(A) = R(A) * R(B)
NOP
NOT
NOT A B - R[A] is #t if R[B] is falsey and #f otherwise
NUMEQ
NUMEQ A B C - compare (=) in register B (inclusive) to C (inclusive) and set R[A] to the result.
NUMGT
NUMGT A B C - compare (>) in register B (inclusive) to C (inclusive) and set R[A] to the result.
NUMGTE
NUMGTE A B C - compare (>=) in register B (inclusive) to C (inclusive) and set R[A] to the result.
NUMLT
NUMLT A B C - compare (<) in register B (inclusive) to C (inclusive) and set R[A] to the result.
NUMLTE
NUMLTE A B C - compare (<=) in register B (inclusive) to C (inclusive) and set R[A] to the result.
ONERR
ONERR A - Make R(A) the current error handler and put the previous error handler in R(A). If R(A) is nil then remove error handler.
REFI
REGB
REGC
REGF
REGI
REGN
REGT
RET
SET
SETCOL
SRET
STACK_BASE ๐Ÿ”’
STR
STR A B C - R(A) = string concatenated from objects in R(A) - R(B) (inclusive)
STRING_BASE ๐Ÿ”’
Strings
SUB
SUB A B - set R(A) = R(A) - R(B)
TCALL
TCALL A B - Tail Call fn R(A) with B args with existing stack/regs
TCALLG
TCALLG A B - Tail Call fn G[A] with B args with existing stack/regs
TCALLM
TCALLM B - Tail Call current fn with B args with existing stack/regs
TYPE
TYPE A B - R(A) = type(R(B)) as a StringConst
TYPE_BASE ๐Ÿ”’
Types
VEC
VEC A B C - R(A) = vec(elements R(B)..R(C)) (R(B) inclusive, R(C) exclusive)
VECELS
VECELS A B - make the length of vec in R(A) R(B)
VECMK
VECMK A B - make a vector with R(B) elements and put it in R(A)
VECMKD
VECPOP
VECPOP A B - pop from vec in R(A) to R(B)
VECPSH
VECPSH A B - push R(B) into vec in R(A)
VEC_BASE ๐Ÿ”’
WIDE
XAR
XAR A B - car(R(A)) = R(B)
XDR
XDR A B - cdr(R(A)) = R(B)

Type Aliasesยง

OpCode