Opcodes used by THE VASSAR INTERPRETER Addressing modes _n - an offset from the beginning of memory (global) NEW %n - an offset into the current stack frame @%n - absolute memory address of offset into stack frame @%0 - offset of the start of the stack frame ^_n - see below ^%n - dereference the memory address as a pointer There is no @_n since @_n = _n = n. Source operands can be literals, or a memory addressing mode. Destination operands are always a memory addressing mode. Opcodes (CASE SENSITIVE) add op1, op2, op3 sub op1, op2, op3 div op1, op2, op3 mul op1, op2, op3 computes op1 + op2, op1 - op2, etc result is stored in op3 which must be an address (or alias) fadd, fsub, fdiv, fmul floating point version of the above uminus op1,op2 negates the value of op1 and stores the result in op2 ltof op1, op2 converts op1 from integer to floating point representation stores the result in op2 ftol op1, op2 converts op1 from floating point to integer representation stores the result in op2 move op1, op2 op1 contains a value op2 contains the memory offset of the destination stor op1, op2, op3 saves op1 in op3[op2] (array style access) op1 contains a value op3 contains the memory offset of the destination op2 contains the offset from op3 load op1, op2, op3 loads op1[op2] into op3 (array style access) op1 contains the memory offset of the source op2 contains an offset from op1 op3 contains the memory offset of the destination goto op1 op1 contains a number, execution will jump to the instruction labeled with op1. blt op1, op2, op3 if ip1 < op2 goto op3 op1, op2 contain values op3 contains a label ble op1, op2, op3 if ip1 <= op2 goto op3 op1, op2 contain values op3 contains a label bgt op1, op2, op3 if ip1 > op2 goto op3 op1, op2 contain values op3 contains a label bge op1, op2, op3 if ip1 >= op2 goto op3 op1, op2 contain values op3 contains a label beq op1, op2, op3 if ip1 = op2 goto op3 op1, op2 contain values op3 contains a label bne op1, op2, op3 if ip1 <> op2 goto op3 op1, op2 contain values op3 contains a label ceq op1, op2, op3 cne op1, op2, op3 clt op1, op2, op3 cgt op1, op2, op3 cle op1, op2, op3 cge op1, op2, op3 similar to the above branching instructions but stores one in op3 if the comparison is true, zero otherwise print op1 prints op1 as a string op1 is a literal string or a STR variable outp op1 op1 is a memory offset, outputs the number stored at that offset. inp op1 causes an input action, a value (number) will be read from stdin and stored to op1 foutp, finp floating point versions of the above newl outputs a carriage return param op1 pushes op1 onto the parameter stack used to prepare for a function call call name, count name is the function name count contains the number or parameters push on the stack with param nop does nothing exit terminates execution of the program alloc n adds 'n' storage locations to the current stack frame free n releases 'n' storage locations from the current stack frame PROCBEGIN name marks the begining of a function declaration PROCEND marks the end of a function DATA declares the beginning of a data section CODE declares the beginning of a code section LONG x, y=n declares the variable x and y, y will be initialized to n at startup STR s="Hello world" declares the constant string s STR variables MUST BE INITIALIZED they ARE NOT arrays of char