The PSL Implementation Guide. |
The machine has 65536 bytes of instruction memory (and hence, 16 bit code addresses) and 256 variables (and hence 8 bit data addresses). Each variable can be a 32 bit integer, an IEEE single precision float or a character string of arbitary length.
In addition, there is a 256 element stack - each entry of which can contain any PSL data type.
The machine has just two registers - the Program Counter (PC) and the Stack Pointer (SP) - neither of which are accessible to running programs directly.
The hex numbers for these opcodes are listed in plib/src/psl/pslOpcodes.h
EFFECT: | Produces a 'Suspicious Opcode' error message and halts the program. Generally, programs that run amok for some reason (eg an error in the compiler) will hit a zero byte fairly soon afterwards. Hence instruction 0x00 is reserved to be the BAD instruction. Other unrecognised instructions are also flagged as errors - but it's useful to explicitly reserve opcode 0x00 for this function due to the high probability of it being executed by broken programs. |
EFFECT: | Updates the 'current line number' from the two bytes embedded in the instruction. |
EFFECT: | Takes four bytes from the instruction and pushes them onto the stack as an integer. |
EFFECT: | Takes four bytes from the instruction and pushes them onto the stack as a float. |
EFFECT: | Takes a null-terminated string from the instruction stream and pushes it onto the stack. |
EFFECT: | Fetches the value of a function's parameter from the
depths of the stack and puts it into a local variable.
The second byte of the instruction is the index of the variable. The third byte is a small integer offset - which is the number of the parameter you want. Look at the number two down from the top of the stack (which should be the number of parameters of a recently called function).
Now copy the stack element at
|
EFFECT: | Throws away the top element of the stack. |
EFFECT: | The second byte of the instruction is the index of
a PSL 'extension function', the third
is the number of arguments being passed to it.
Pop that number of values off the stack and pass them to the extension function. Call the extension function. Push the result onto the stack. |
EFFECT: | [The number of aguments will already have been pushed
onto the stack.]
The four bytes after the instruction is the function address. The fifth byte is the number of arguments.
Push return address.
popNumber ( &result ) ; |
EFFECT: | Duplicate the top element of the stack. |
EFFECT: | Exchange the top two elements of the stack. |
EFFECT: | Pop the top element from the stack and operate on it
and the next element down - leaving the result on
the stack in it's place. So (for example) if the
operation was 'SUB' (Subtract), and A is on top of
the stack and B is beneath it - then the result of
this operation would be to leave (B-A) on the stack
with no sign of either A or B.
The 'ADD' operator also works with strings by concatenating them. |
EFFECT: | Perform the C unary '!', '~' or '-' operator on the top element of the stack. |
EFFECT: | Informs application program that the script wishes to be paused until next frame. |
EFFECT: | Informs the application that the script wishes to halt. Even if the application ignores this request, the script will continue looping at this location for ever. |
EFFECT: | The two bytes at the end of the instruction contain an address. Inspect the number off the top of the stack (without popping it) - and branch to the specified instruction if the value is TRUE (or FALSE as applicable). |
EFFECT: | The two bytes at the end of the instruction contain an address. POP the number off the top of the stack (without popping it) - and branch to the specified instruction if the value is TRUE (or FALSE as applicable). |
EFFECT: | The two bytes at the end of the instruction contain an address. Jump to that address. |
EFFECT: | The second byte of the instruction is the index of a variable. The value of that variable is pushed onto the stack. |
EFFECT: | Three things are on the stack when this function is called. The thing on top is the result of an expression evaluation. The thing beneath that is the index of a variable. The thing beneath that is the dimension of the variable. The value is added to/subtracted from/multiplied by/etc the variable - and stored back into the variable. The new value of the variable is left on the stack. |
EFFECT: | Three things are on the stack when this function is called. The thing on top is the result of an expression evaluation. The thing beneath that is the index of a variable. The thing beneath that is the dimension of the variable. The value is stored into the variable. The new value of the variable is left on the stack. |
EFFECT: | The second byte of the instruction is the index of an array
variable. On the top of the stack is an integer. This instruction allocates that number of elements of storage to the array. |
EFFECT: | The second byte of the instruction is the index of a variable. That variable is created, set to the appropriate type and initialised appropriately. |
EFFECT: | The index of a variable is on top of the stack. The thing beneath that is the dimension of the variable. Replace those with the value of that variable. |
EFFECT: | The index of a variable is on top of the stack. The thing beneath that is the dimension of the variable. Replace those with the value of that variable. Post-increment/decrement the variable. |
EFFECT: | The index and dimension of a variable is on top of the stack. Increment/decrement the variable leaving the stack contents undisturbed. |