#ifndef OPCODES_H #define OPCODES_H /* opcodes.h XIDEK: Extensible Script Language Development Kit Opcode Definitions Copyright (c) 1996-2002 Parsifal Software. All Rights Reserved. For further information about this program or the AnaGram parser generator, please contact: Parsifal Software http://www.parsifalsoft.com info@parsifalsoft.com +1-800-879-2577, Voice/Fax +1-508-358-2564 P.O. Box 219 Wayland, MA 01778 USA */ // Virtual machine instruction list // Caution! don't add entries to this list without making corresponding // additions to const char *opcodeText[] in bcidefs.cpp enum Opcode { // Opcodes with no operand; one byte-code-size long. HLT, // Stop execution FETCH, // Fetch value addressed by top stack element I_FETCH, // Increment, then fetch value adressed by top of stack D_FETCH, // Decrement, then fetch value adressed by top of stack FETCH_I, // Fetch, then increment value addressed by top of stack FETCH_D, // Fetch, then increment value addressed by top of stack STORE, // pop top of stack, store indirect through lvalue that // is next on stack and replace lvalue with the stored value POP, // discard top element of stack SAP, // Store and pop, PRINT, // Pop top stack element and print it RETURN, // Binary operators: pop two values off stack, compute, push result ADD, // Add SUB, // Subtract MUL, // Multiply DIV, // Divide IDIV, // Integer Divide RDIV, // Real divide MOD, // Remainder POW, // Raise to power AND, // And IOR, // Inclusive or XOR, // Exclusive or LS, // Left shift RS, // Right shift /* * Binary operators on memory: * pop top stack element, * pop pointer from stack * fetch value through pointer * compute, * then push result and also store it through pointer */ ADDM, // Add to memory (variable) SUBM, // Subtract from memory (variable) MULM, // Multiply with memory (variable) DIVM, // Divide by memory (variable) MODM, // Remainder to memory ANDM, // And to memory (variable) IORM, // Inclusive or to memory (variable) XORM, // Exclusive or to memory (variable) LSM, // Left shift memory (variable) RSM, // Right shift memory (variable) POWM, // Raise memory to power // Comparison operators: pop two values off stack, push zero or nonzero LT, // < LE, // <= GT, // > GE, // >= EQ, // == NE, // != // Unary operators: pop value from stack, compute, push result NEG, // Negate top element on stack NOT, // Logical NOT of top element on stack COM, // bitwise complement // Cast operators CAST_LONG, // Make value long CAST_DOUBLE, // Make value double /* * Opcodes with one operand; two byte-code-sizes long. * In the descriptions, the value of the operand is represented with "K". */ LOCATE, // Push address of variable no. K onto stack PUSHC, // Push value of constant no. K onto stack DUMP, // Print name and value of variable no. K. /* Branch instructions: K is the offset in number of bytecodes relative to the address of the instruction after the branch instruction. That is, BR -2 is an infinite loop. */ LAND, // branch on false; pop top stack element if not taken LOR, // branch on true; pop top stack element if not taken BR, // branch unconditionally BRF, // branch on false, always pop top stack element BRT, // branch on true, always pop top stack element CALL, // call K'th function in function table RPT, // repeat block n times }; #endif