 Robot Warfare 1
 RW0 bytecode description
 Version 1.99

 Alexander A. Shabarshin (shaos@mail.ru)
 http://robots.ural.net

 November 1998 - January 2000

 Header:
 -------

0x0000: 0x00..0x02 // Version (0x00 for 1.*, 0x01 for 1.99, 0x02 for 2.0)
0x0001: 2 bytes // CheckSum (simple adding of the bytes starting from 0x0005)
0x0003: 2 bytes // Offset to bytecode start point (in bytes)
0x0005: 1 byte  // Length of the robot name (strlen)
0x0006: N bytes // Robot name
0x????: 0x00    // Terminal character for robot name
0x????: 2 bytes // Number of variables (plus arrays length)
0x????: 2 bytes // Code length in bytes (beginning from start point)
0x????: 3 bytes // Robot color (R,G,B)
0x????: 4 bytes // Equipments on the FRONT,RIGHT,BACK,LEFT (0-empty,1-eye,2-gun)
0x????: 1 byte  // Image flag (0x00-image is absent, 0x20-image is present)
// if image present, then next 32 bytes describe the robot image (2pix/byte)
// after that follows bytecode (after start point)
0x????: N bytes // Author nickname
0x????: 0x00    // Terminal character for author nickname
0x????: ?? ...  // reserved for additional data
START:

-----------------------------------------------------------------
 B - byte (1 byte)
 W - word (2 bytes - low byte + high byte)
 M - variable or constant (3-5 bytes):
     0x00 W - signed integer (-32K..+32K)
     0x01 W - variable in W cell (array[constant] is compiled to it too)
     0x02 W1 W2 - array element (W1-begin of array, W2-variables with offset)
 Registers are variables (0x01 0x?? 0xFF) with the addresses:
 0xFF00 - X // register for relative X value
 0xFF01 - Y // register for relative Y value
 0xFF02 - D // register for distance value
 0xFF03 - N // register for object value
 0xFF04 - K // register for additional value
 0xFF05 - R // register for random value
 0xFF06 - T // register for timer value
 0xFF07 - E // register for our energy value
 0xFF08 - M // register for our missiles number
 0xFF09 - I // register for order number of robot
 0xFF0F - S // register for stack length

 labW - label with address W
-----------------------------------------------------------------

 DEF commands - array definition (minimal length is 5 bytes)
 ------------

 0x01 W1 W2 // DEF arr[len]  (W1-offset to array start, W2-len)
 0x02 W1 W2 W3 ... // DEF arr[len]={list}  (W3-number of words)

 IF commands - maximal length is 13 bytes
 -----------

 0x10 W M1 M2 // IF M1<M2 : labW
 0x11 W M1 M2 // IF M1>M2 : labW
 0x12 W M1 M2 // IF M1<=M2 : labW
 0x13 W M1 M2 // IF M1>=M2 : labW
 0x14 W M1 M2 // IF M1==M2 : labW
 0x15 W M1 M2 // IF M1!=M2 : labW
           // or IF M1<>M2 : labW

 Expressions - maximal length is 11-16 bytes
 -----------

 0x20 M1 M2 // M1=M2
 0x21 M1 M2 // M1=-M2
 0x22 M1 M2 M3 // M1=M2+M3
 0x23 M1 M2 M3 // M1=M2-M3
 0x24 M1 M2 M3 // M1=M2/M3
 0x25 M1 M2 M3 // M1=M2*M3
 0x26 M1 M2 M3 // M1=M2%M3
 0x27 M1 M2 M3 // M1=M2&M3 - binary AND
 0x28 M1 M2 M3 // M1=M2|M3 - binary OR
 0x29 M1 M2 M3 // M1=M2^M3 - binary XOR
 0x2A M1 M2 // M1=~M2 - binary NOT

 Simple commands - 1-5 bytes
 ---------------

 0x30 W // GOTO labW
 0x31 W // CALL labW
 0x33 // RET
 0x34 // STEP
 0x35 // LEFT
 0x36 // RIGHT
 0x37 string 0x00 // SAY "string"
 0x38 M // print M
 0x3A M // ACT M (FRONT=0,RIGHT=1,BACK=2,LEFT=3)
 0x3B   // SPY
 0x3C M // RADAR M
 0x3F 0x00 B // DUMP variables in the B columns  (3 bytes)

 0x51 W wildcard-string 0x00 // TEST "wildcard" : label

 0x60 M // SHOT var
 0x61 M1 M2 // SEND var1 var2 - send code var1 to robot var2
 0x62 M // RECV var - receive code and save it to var
 0x63   // POP

 0xFF // END - end of bytecode
