The Robot Machine Code.

The following is a listing of what each of the Machine instructions
do,and what each of the parameters are.

Opcode:

1:	 Begin

Begin must be the first line of code. It takes 3 op Codes. The first
is the line number where the main program starts. The second is the
number of local variables to main. The third is the number of global
variables.

This OpCode sets up the stack as follows:

First, space for any global data is allocated. Then, the frame pointer
is added to the stack. Then local data is allocated. Finally, the stack
pointer is set to the top stack location, currently the last local data
location.


For a program with 2 local variables and 2 local variables, the stack
would look like this.

	|__|
  5|__| <- local variable  <- initial stack pointer
  4|__| <- local variable
  3|__| <- frame pointer
  2|__| <- global variable
  1|__| <- global variable

  bottom

2:  Procedure

Procedure sets up the stack at the beginning of a procedure execution.
It has three opcodes, being:

	1: Number of Parameters
	2: Number of Local data
	3: Block number of the proceedure

It saves the old frame pointer, and stack pointer, and allocates space
for the local data. The new stack pointer is set to the last local
data item (as if starting with a begin).

3:  End

	This terminates normal execution of the code

4:  Procedure End

	This returns from a procedure. The saves Stack Pointer and Frame
	Pointer are restored. The Instruction Pointer is set to the line
	after the procedure was called. The stack is then cleared of all
	data relevant to that procedure. A 0 value is placed on top of the
	stack, as no return value was specified.

5:  Statement

	This removes a value from the stack, decrementing the stack pointer.

6:  Pop and Jump False

	This instruction has one opcode. It removes the top value from the
	stack, and if the value found is 0, jumps to the line specified
	by the opcode.

7:  Jump

	This instruction has one opcode. It jumps to the line of code
	specified by this opcode.

10: Return

	Return does the same thing as Procedure End, but rather than leaving
	a zero on the top of the stack, it takes the top stack value when
	executed, and replaces it on top of the stack after clearing the data
	areas.

11: Negation

	Negation inverses the sign of the value on the top of the stack.
	For example: 1 would become -1.

12: Not

	Not takes the value on top of the stack, and if it is 0, makes it
	a 1. If it is not 0, it makes it 0.

13: Load Array

	This loads the address of an array index. The exact array
	index is on top of the stack when this opcode executes. There
	are 2 parameters for loading a value. The first is the offset of
	the array, and the second is the block number the variable is
	defined in. If the block number is 0, then it is global data,
	otherwise it is local.
	The offset is used to determine which variable is being looked for.
	A positive offset is added to the frame pointer to load the address
	of a variable. (In case of global data, the offset is added to 0.)


14: Load Address

	This is much like the Load Array instruction, except it works with
	normal variables. The block number and offset fields are the same.
	Normal variables can be passed as parameters. Parameters have
	negative offsets, which are subtracted from the frame pointer.

15: Call Procedure

	This saves the current Instruction Pointer value on the stack
	(a return address) and then jumps to the line of code specified
	by the first opcode value. This line of code needs to be a
	Procedure instruction. Any parameters that get passed to the
	procedure need to have been loaded onto the stack before this
	instruction executes.



16: Call Predefined

	This calls a predefined function. The second opcode field is the
	code number for the predefined function. The first opcode is not
	used by the interpreter, but contains the expected number of
	parameters for a given predefined function.

17: Value

	This changes an address on the stack to the value contained at that
	address.

18: Assign

	This stores the value on top of the stack to the location specified
	one below the top of the stack. It pops the top value, but saves that
	value on the new top, where the address used to be.

19: List

	This is an instruction only used by the compiler. The optimizer
	in the compiler should remove and list instructions.
	(What this does is count the number of variables passed to a
	procedure, and then compare that with the number the procedure
	expected to receive.)

20: Number

	This places a number on the top of the stack. The number is given
	as the first opcode.

21: Square

	This pops a value from the stack (i), and raises the number
	which is then on top (j) to that power. (j^i)

22: Multiply

	This multiplies the top two values on the stack, saving the
	result in their place on top of the stack.

23: Divide

	This divides the top two stack values. The Top element (i) is
	the denomenator, while the value below it is the numerator.
	The new value replaces both the above on the stack.

24: Modulus

	Much the same as divide, although returning the remainder from the
	division

25: Add

	Adds the top two stack values.

26: Subtract

	Subtracts the top stack value from the value below it on the stack.
	As with other math functions, the result replaces both values.

27: Equal
28: Less Than or Equal
29: Less Than
30: Not Equal
31: Greater Than or Equal
32: Greater Than

	All of the above are relational operators. They compare the top
	stack value to the value below it, and replace the both with
	1: if the relationship is true
	0: if the relationship is false

	As with The math, when the order of the operands matters, the value
	on top of the stack is the right hand value, and the value below it
	is the left hand value.

33: Jump False or Pop

	Jumps to the line specified by opcode 1 if the value on top of the
	stack is false, otherwise removes that value from the stack.

34: Jump True or Pop

	Jumps to the line specified by opcode 1 if the value on top of the
	stack is true, otherwise removes that value from the stack.

35: Load Value

	Directly loads the value found at location specified by offset and
	block	number. As with Load address, the offset is the first opcode,
	and the block number is the second opcode.

36: No Op

	Do nothing. This should never appear in code, as the optimizer
	removes no-ops.

37: Block

	Adds a value to the stack. This is important sometimes in balancing
	the stack. THe value added is 0.


The Predefined Functions

1:  Radar

	Sends a radar pulse at the angle specified by the top of the
	stack. The return value is placed on top of the stack.

2:  Fire

	Fires a shot at the angle specified by the top of the stack.
	The value is unchanged if the shot is fired, and set to 0 if
	the gun was cooling.

3:  SpeedX

	Sets the robot's horizontal speed to the value on top of the
	stack. Value is unchanged.

4:  SpeedY

	Sets the robot's vertical speed to the value on top of the stack.
	Value is unchanged.

5:  LocX

	Places the robot's X location on top of the stack.

6:  LocY

	Places the robot's Y location on top of the stack.

7:  Random

	Replaces the top of the stack with a random number between 0 and
	the value on top of the stack.

8:  Damage

	Places the robot's current damage status on top of the stack.

9:  Goto

	Sets the robot's destination registers to the values on top of the
	stack, with Y being the upper value.

10: Hit

	Places a the hit result on top of the stack. See programming
	manual for description of the hit result.

11: GetSpeedX

	Places the robot's current horizontal speed on the stack.

12: GetSpeedY

	Places the robot's current vertical speed on the stack.

13: GetAngle

	Removes a Y value from the stack. Then removes an X value. Then
	computes an angle, and adds it to the stack.

14: GetX

	Removes a distance from the stack. Then removes an angle from the
	stack. Then computes a X offset and puts it on the stack.

15: GetY

	Removes a distance from the stack. Then removes an angle from the
	stack. Then computes a Y offset and puts it on the stack.

16: GetNum

	Places the number of robots left in the game on top of the stack.

17: DistFire

	Removes a distance from the stack. Then fires a distance triggered
	projectile at the angle found on top of the stack. Changes that
	value to a 0 if the gun was reloading.

18: Wait

	Sets the robots delay for a number of ticks equal to the value on
	top of the stack. Value is unchanged

19: Left

	Puts the Leftmost coordinate on the stack.

20: Right

	Puts the Rightmost coordniate on the stack.

21: Top

	Puts the upper coordinate on the stack.

22: Bottom

	Puts the lower coordinate on the stack.

23: Repair

	Initiates self repair. Places a 1 on the stack.

24: There

	Places a 1 on the stack if both destination registers are set to
	off. Otherwise puts a 0 on the stack.
