There are 13 named opcodes, 1 unnamed opcodes, 15 symboled opcodes, 4 reference constructs, a static string construct, and a static integer construct.
Comments appear in the unassembled pcode as a semicolon, followed by the comment, and terminated by an eol character.
Named opcodes appear in the unassembled p-code as keyword names, and appear in the assembled p-code as char sized unsigned integers.
The definitions of the named opcodes are as follows.
/ref call #retval
The call opcode invokes a p-code segment. Upon completion, the return value of the segment is pushed on the stack.
#delay /ref alarm
The alarm opcode invokes a p-code section after the specified delay.
#sig /ref signal
The signal opcode invokes a p-code section upon the overlord receiving the specified signal.
Valid signals are #1 (SIGUSR1) and #2 (SIGUSR2).
Note: The handler is cleared once the signal is triggered.
/ref sigchild
the sigchild opcode invokes a p-code section when the overlord receiving the sigchild signal and the waitpid() call returns a pid matching the pid in the current context.
Note: The handler is cleared once the signal is triggered.
args .. args (nebuloid) get returnval
The get opcode invokes a nebuloid's get function with the provided args. Once completed, the return value from the nebuloid is pushed onto the stack.
value (nebuloid) set
The set opcode invokes a nebuloid's set function with the provided value.
getpid #pid
The getpid opcode retrieves the pid associated with the current context and places it on the stack.
#pid setpid
The setpid opcode associates the provided pid with the current context.
#retval return
The return opcode stops execution of the current p-code segment, and returns to executing the calling segment if the segment was called from pcode, or waits for an alarm/signal to retrigger execution.
The #retval argument is pushed back onto the stack after it is trimmed if the segment was called from pcode, otherwise it is discarded.
args .. args #local &module (nebuloid) inst
The inst opcode instantiates an instance of a nebuloid. It binds a module to a nebuloid name in either the global or local context (depending if the local arg evaluates as true or false), and passes the provided args to the nebuloid's instantiation routine.
(nebuloid) dinst
The dinst opcode de-instantiates an instance of a nebuloid.
arg drop
The drop opcode takes one argument and then ignores it. Used to pop an unneeded item off the stack.
arg dup arg arg
The dup opcode takes one argument and pushes a second copy to the stack.
There is currently only one unnamed opcode.
#ctx context
The context opcode does not directly appear in the unassembled p-code. It is evaluated from the context reference construct, described below.
#boolean
{
}
#boolean
The { (if) opcode takes one argument from the stack. If the argument evaluates as true, the code following the opcode is executed, otherwise all code until the matching } (fi) opcode is skipped.
The } (fi) opcode terminates an if block, and pushes the logical negation of the originally if'ed value onto the stack.
[
#boolean
]
The [ (for) opcode marks the beginning of the loop.
The ] (rof) opcode takes one argument from the stack. If the argument evaluates as true, the flow of execution jumps to the matching [ (for) opcode, otherwise the code following the ] (rof) opcode is executed.
#arg1 #arg2 oper #result
The binary logical opcodes take two arguments and evaluate them in the form:
result = arg2 oper arg1
These opcodes are as follows:
#arg1 #arg2 oper #result
The binary arithmetical opcodes take two arguments and evaluate them in the form:
result = arg1 oper arg2
These opcodes are as follows:
#arg oper #result
The unary opcodes are as follows:
Reference constructs are higher level functions of the unassembled p-code language that make writing p-code by hand at little bit easier.
There are 4 reference constructs, which are as follows.
p-code: @string
compiled: [nothing]
The mark construct marks the start of a p-code segment. It does not have an inline representation in the compiled p-code, instead it is represented in a p-code segment table.
p-code: /string
compiled: #index
The reference construct references the start of the named p-code segment. It is represented by a numeric index into the segment table in the compiled p-code.
p-code: %string
compiled: #index context
The context construct changes the current local nebuloid context. It is represented by a numeric index into the context table followed by the unnamed context opcode in the compiled p-code.
p-code: &string
compiled: #index
The module construct references a module by name, for use as an argument in the inst opcode.
All module constructs appearing in the p-code are collected into the module table, which is used to determine the index number.
Strings and numbers.
(Some String)
The string construct is represented by an open bracket (, followed by the string itself, then terminated with a close bracket ). It is copied verbatim into the compiled p-code, brackets included.
#12345
The integer construct is represented by a pound (octothorpe) character #, followed by a signed 64-bit value. It is represented in the compiled p-code as an integer opcode followed by 64-bits of signed integer.