Very Primitive Language (VPL)

InstructionMnemonicSemantic Description
0no op Do nothing.
1 LlabelDuring program loading this instruction disappears, and all occurrences of L are replaced by the actual index in mem where the opcode 1 would have been stored.
2 Lcall Do all the steps necessary to set up for execution of the subprogram that begins at label L.
3 apass Push the contents of cell a on the stack.
4 n localsIncrease sp by n to make space for local variables in the current stack frame.
5 areturnDo all the steps necessary to return from the current subprogram, including putting the value stored in cell a in rv.
6 aget retvalCopy the value stored in rv into cell a.
7 LjumpChange ip to L.
8 L a condIf the value stored in cell a is non-zero, change ip to L (otherwise, move ip to the next instruction).
9 a b cadd Add the values in cell b and cell c and store the result in cell a.
10 a b csubtractSame as 9, but do cell b − cell c.
11 a b cmultiplySame as 9, but do cell b * cell c.
12 a b cdivideSame as 9, but do cell b / cell c.
13 a b cremainderSame as 9, but do cell b % cell c.
14 a b cequalSame as 9, but do cell b == cell c.
15 a b cnot equalSame as 9, but do cell b != cell c.
16 a b cless thanSame as 9, but do cell b < cell c.
17 a b cless than or equal Same as 9, but do cell b <= cell c.
18 a b candSame as 9, but do cell b && cell c.
19 a b corSame as 9, but do cell b || cell c.
20 a bnotIf cell b holds zero, put 1 in cell a, otherwise put 0 in cell a.
21 a boppositePut the opposite of the contents of cell b in cell a.
22 a nliteralPut n in cell a.
23 a bcopyCopy the value in cell b into cell a.
24 a b cgetGet the value stored in the heap at the index obtained by adding the value of cell b and the value of cell c and copy it into cell a.
25 a b cputTake the value from cell c and store it in the heap at the location with index computed as the value in cell a plus the value in cell b.
26haltHalt execution.
27 ainputPrint a ? and a space in the console and wait for an integer value to be typed by the user, and then store it in cell a.
28 aoutputDisplay the value stored in cell a in the console.
29newlineMove the console cursor to the beginning of the next line.
30 asymbolIf the value stored in cell a is between 32 and 126, display the corresponding symbol at the console cursor, otherwise do nothing.
31 a bnewLet the value stored in cell b be denoted by m. Decrease hp by m and put the new value of hp in cell a.
32 nallocate global spaceThis instruction must occur first in any program that uses it. It simply sets the initial value of sp to n cells beyond the end of stored program memory, and sets gp to the end of stored program memory.
33 n aCopy to globalCopy the contents of cell a to the global memory area at index gp+n.
34 a nCopy from globalCopy the contents of the global memory cell at index gp+n into cell a.