/* * This file contains a listing of all of the bytecode commands - they are * numbered in the order that they appear in this file, starting with zero. * Most of the commands are documented explicitly in the Maestro User's Guide, * but there are several special commands: * * LITERAL8 / LITERAL consume an additional one / two bytes from the bytecode * and copy those to the stack. * * LITERAL8_N / LITERAL_N are more efficient for long lists of literals, * taking first a byte that represents the number of additional bytes to * consume, then copying those bytes to the stack as 8-bit / 16-bit * values. The first byte after LITERAL_N must therefore be an even * number. * * JUMP consumes an additional two bytes specifying an address to jump to. * * JUMP_Z removes a value from the stack, then does a JUMP if the value is zero. * * CALL is just like JUMP, but it pushes the current program counter to the * call stack before jumping to the subroutine. This command is NOT * available on the Micro Maestro. * * The addresses of the first 128 subroutines are stored in a special location in * memory so that you only need a single bytecode command to call them - commands * 128-255 are reserved for this purpose. Please download our USB SDK from * * http://www.pololu.com/docs/0J41 * * and take a look at the functions writeScript and setSubroutines in Usc.cs - these * will show you how to load the bytecode and subroutine list into the Maestro. * */ namespace Pololu.Usc.Bytecode { public enum Opcode { QUIT, // literals LITERAL, LITERAL8, LITERAL_N, LITERAL8_N, // Control RETURN, JUMP, JUMP_Z, // Timing DELAY, GET_MS, // Stack DEPTH, DROP, DUP, OVER, PICK, SWAP, ROT, ROLL, // Bitwise BITWISE_NOT, BITWISE_AND, BITWISE_OR, BITWISE_XOR, SHIFT_RIGHT, SHIFT_LEFT, // Boolean logic LOGICAL_NOT, LOGICAL_AND, LOGICAL_OR, // Unary math operations NEGATE, // Binary math operations PLUS, MINUS, TIMES, DIVIDE, MOD, // Mathematical logic POSITIVE, NEGATIVE, NONZERO, EQUALS, NOT_EQUALS, MIN, MAX, LESS_THAN, GREATER_THAN, // servo settings SERVO, SERVO_8BIT, SPEED, ACCELERATION, GET_POSITION, GET_MOVING_STATE, LED_ON, LED_OFF, // WARNING: the following commands are not available on the Micro Maestro. // pwm PWM, // higher-level language support PEEK, POKE, // serial SERIAL_SEND_BYTE, // allowing more than 128 subroutines CALL } // NOTE: If you add an opcode, update the computed goto's code that // checks (see "maximum valid opcode" in bytecode_asm.asm }