1 /* $Header: d:/cvsroot/tads/tads3/vmop.h,v 1.4 1999/07/11 00:46:59 MJRoberts Exp $ */ 2 3 /* 4 * Copyright (c) 1998, 2002 Michael J. Roberts. All Rights Reserved. 5 * 6 * Please see the accompanying license file, LICENSE.TXT, for information 7 * on using and copying this software. 8 */ 9 /* 10 Name 11 vmop.h - T3 VM Opcodes 12 Function 13 14 Notes 15 16 Modified 17 11/14/98 MJRoberts - Creation 18 */ 19 20 #ifndef VMOP_H 21 #define VMOP_H 22 23 #define OPC_PUSH_0 0x01 /* push constant integer 0 */ 24 #define OPC_PUSH_1 0x02 /* push constant integer 1 */ 25 #define OPC_PUSHINT8 0x03 /* push SBYTE operand as integer */ 26 #define OPC_PUSHINT 0x04 /* push INT4 operand as integer */ 27 #define OPC_PUSHSTR 0x05 /* push UINT4 operand as string constant */ 28 #define OPC_PUSHLST 0x06 /* push UINT4 operand as list constant */ 29 #define OPC_PUSHOBJ 0x07 /* push UINT4 operand as object ID */ 30 #define OPC_PUSHNIL 0x08 /* push nil */ 31 #define OPC_PUSHTRUE 0x09 /* push true */ 32 #define OPC_PUSHPROPID 0x0A /* push UINT2 operand as property ID */ 33 #define OPC_PUSHFNPTR 0x0B /* push UINT4 code offset */ 34 #define OPC_PUSHSTRI 0x0C /* push inline string constant */ 35 #define OPC_PUSHPARLST 0x0D /* push varargs parameter list */ 36 #define OPC_MAKELSTPAR 0x0E /* push varargs parameter from list */ 37 #define OPC_PUSHENUM 0x0F /* push an enum value */ 38 39 #define OPC_NEG 0x20 /* negate */ 40 #define OPC_BNOT 0x21 /* bitwise NOT */ 41 #define OPC_ADD 0x22 /* add */ 42 #define OPC_SUB 0x23 /* subtract */ 43 #define OPC_MUL 0x24 /* multiply */ 44 #define OPC_BAND 0x25 /* bitwise AND */ 45 #define OPC_BOR 0x26 /* bitwise OR */ 46 #define OPC_SHL 0x27 /* shift left */ 47 #define OPC_SHR 0x28 /* shift right */ 48 #define OPC_XOR 0x29 /* bitwise/logical XOR */ 49 #define OPC_DIV 0x2A /* divide */ 50 #define OPC_MOD 0x2B /* MOD (remainder) */ 51 #define OPC_NOT 0x2C /* logical NOT */ 52 #define OPC_BOOLIZE 0x2D /* convert top of stack to true/nil */ 53 #define OPC_INC 0x2E /* increment value at top of stack */ 54 #define OPC_DEC 0x2F /* decrement value at top of stack */ 55 56 #define OPC_EQ 0x40 /* equals */ 57 #define OPC_NE 0x41 /* not equals */ 58 #define OPC_LT 0x42 /* less than */ 59 #define OPC_LE 0x43 /* less than or equal to */ 60 #define OPC_GT 0x44 /* greater than */ 61 #define OPC_GE 0x45 /* greater than or equal to */ 62 63 #define OPC_RETVAL 0x50 /* return with value at top of stack */ 64 #define OPC_RETNIL 0x51 /* return nil */ 65 #define OPC_RETTRUE 0x52 /* return true */ 66 #define OPC_RET 0x54 /* return with no value */ 67 68 #define OPC_CALL 0x58 /* function call */ 69 #define OPC_PTRCALL 0x59 /* function call through pointer */ 70 71 #define OPC_GETPROP 0x60 /* get property */ 72 #define OPC_CALLPROP 0x61 /* call property with arguments */ 73 #define OPC_PTRCALLPROP 0x62 /* call property through pointer with args */ 74 #define OPC_GETPROPSELF 0x63 /* get property of 'self' */ 75 #define OPC_CALLPROPSELF 0x64 /* call method of 'self' */ 76 #define OPC_PTRCALLPROPSELF 0x65 /* call method of 'self' through pointer */ 77 #define OPC_OBJGETPROP 0x66 /* get property of specific object */ 78 #define OPC_OBJCALLPROP 0x67 /* call method of specific object */ 79 #define OPC_GETPROPDATA 0x68 /* get property, disallowing side effects */ 80 #define OPC_PTRGETPROPDATA 0x69 /* get prop through pointer, data only */ 81 #define OPC_GETPROPLCL1 0x6A /* get property of local variable */ 82 #define OPC_CALLPROPLCL1 0x6B /* call property of local variable */ 83 #define OPC_GETPROPR0 0x6C /* get property of R0 */ 84 #define OPC_CALLPROPR0 0x6D /* call property of R0 */ 85 86 #define OPC_INHERIT 0x72 /* inherit from superclass */ 87 #define OPC_PTRINHERIT 0x73 /* inherit through property pointer */ 88 #define OPC_EXPINHERIT 0x74 /* inherit from an explicit superclass */ 89 #define OPC_PTREXPINHERIT 0x75 /* inherit from explicit sc through prop ptr */ 90 #define OPC_VARARGC 0x76 /* modifier: next call is var arg count */ 91 #define OPC_DELEGATE 0x77 /* delegate to object on stack */ 92 #define OPC_PTRDELEGATE 0x78 /* delegate through property pointer */ 93 94 #define OPC_GETLCL1 0x80 /* push a local variable */ 95 #define OPC_GETLCL2 0x81 /* push a local (2-byte index) */ 96 #define OPC_GETARG1 0x82 /* push an argument */ 97 #define OPC_GETARG2 0x83 /* push an argument (2-byte index) */ 98 #define OPC_PUSHSELF 0x84 /* push 'self' */ 99 #define OPC_GETDBLCL 0x85 /* push debug frame local */ 100 #define OPC_GETDBARG 0x86 /* push debug frame argument */ 101 #define OPC_GETARGC 0x87 /* get current argument count */ 102 #define OPC_DUP 0x88 /* duplicate top of stack */ 103 #define OPC_DISC 0x89 /* discard top of stack */ 104 #define OPC_DISC1 0x8A /* discard n items from stack */ 105 #define OPC_GETR0 0x8B /* push the R0 register onto the stack */ 106 #define OPC_GETDBARGC 0x8C /* push debug frame argument count */ 107 #define OPC_SWAP 0x8D /* swap top two stack elements */ 108 109 #define OPC_PUSHCTXELE 0x8E /* push a method context value */ 110 #define PUSHCTXELE_TARGPROP 0x01 /* push target property */ 111 #define PUSHCTXELE_TARGOBJ 0x02 /* push target object */ 112 #define PUSHCTXELE_DEFOBJ 0x03 /* push defining object */ 113 114 #define OPC_SWITCH 0x90 /* jump through case table */ 115 #define OPC_JMP 0x91 /* unconditional branch */ 116 #define OPC_JT 0x92 /* jump if true */ 117 #define OPC_JF 0x93 /* jump if false */ 118 #define OPC_JE 0x94 /* jump if equal */ 119 #define OPC_JNE 0x95 /* jump if not equal */ 120 #define OPC_JGT 0x96 /* jump if greater than */ 121 #define OPC_JGE 0x97 122 #define OPC_JLT 0x98 /* jump if less than */ 123 #define OPC_JLE 0x99 /* jump if less than or equal */ 124 #define OPC_JST 0x9A /* jump and save if true */ 125 #define OPC_JSF 0x9B /* jump and save if false */ 126 #define OPC_LJSR 0x9C /* local jump to subroutine */ 127 #define OPC_LRET 0x9D /* local return from subroutine */ 128 #define OPC_JNIL 0x9E /* jump if nil */ 129 #define OPC_JNOTNIL 0x9F /* jump if not nil */ 130 #define OPC_JR0T 0xA0 /* jump if R0 is true */ 131 #define OPC_JR0F 0xA1 /* jump if R0 is false */ 132 133 #define OPC_SAY 0xB0 /* display a constant string */ 134 #define OPC_BUILTIN_A 0xB1 /* call built-in func from set 0 */ 135 #define OPC_BUILTIN_B 0xB2 /* call built-in from set 1 */ 136 #define OPC_BUILTIN_C 0xB3 /* call built-in from set 2 */ 137 #define OPC_BUILTIN_D 0xB4 /* call built-in from set 3 */ 138 #define OPC_BUILTIN1 0xB5 /* call built-in from any set, 8-bit index */ 139 #define OPC_BUILTIN2 0xB6 /* call built-in from any set, 16-bit index */ 140 #define OPC_CALLEXT 0xB7 /* call external function */ 141 #define OPC_THROW 0xB8 /* throw an exception */ 142 #define OPC_SAYVAL 0xB9 /* display the value at top of stack */ 143 144 #define OPC_INDEX 0xBA /* index a list */ 145 #define OPC_IDXLCL1INT8 0xBB /* index a local variable by an int8 value */ 146 #define OPC_IDXINT8 0xBC /* index by an int8 value */ 147 148 #define OPC_NEW1 0xC0 /* create new object instance */ 149 #define OPC_NEW2 0xC1 /* create new object (2-byte operands) */ 150 #define OPC_TRNEW1 0xC2 /* create new transient instance */ 151 #define OPC_TRNEW2 0xC3 /* create transient object (2-byte operands) */ 152 153 #define OPC_INCLCL 0xD0 /* increment local variable by 1 */ 154 #define OPC_DECLCL 0xD1 /* decrement local variable by 1 */ 155 #define OPC_ADDILCL1 0xD2 /* add immediate 1-byte int to local */ 156 #define OPC_ADDILCL4 0xD3 /* add immediate 4-byte int to local */ 157 #define OPC_ADDTOLCL 0xD4 /* add value to local variable */ 158 #define OPC_SUBFROMLCL 0xD5 /* subtract value from local variable */ 159 #define OPC_ZEROLCL1 0xD6 /* set local to zero */ 160 #define OPC_ZEROLCL2 0xD7 /* set local to zero */ 161 #define OPC_NILLCL1 0xD8 /* set local to nil */ 162 #define OPC_NILLCL2 0xD9 /* set local to nil */ 163 #define OPC_ONELCL1 0xDA /* set local to numeric value 1 */ 164 #define OPC_ONELCL2 0xDB /* set local to numeric value 1 */ 165 166 #define OPC_SETLCL1 0xE0 /* set local (1-byte local number) */ 167 #define OPC_SETLCL2 0xE1 /* set local (2-byte local number) */ 168 #define OPC_SETARG1 0xE2 /* set parameter (1-byte param number) */ 169 #define OPC_SETARG2 0xE3 /* set parameter (2-byte param number) */ 170 #define OPC_SETIND 0xE4 /* set value at index */ 171 #define OPC_SETPROP 0xE5 /* set property in object */ 172 #define OPC_PTRSETPROP 0xE6 /* set property through prop pointer */ 173 #define OPC_SETPROPSELF 0xE7 /* set property in self */ 174 #define OPC_OBJSETPROP 0xE8 /* set property in immediate object */ 175 #define OPC_SETDBLCL 0xE9 /* set debugger local variable */ 176 #define OPC_SETDBARG 0xEA /* set debugger parameter variable */ 177 178 #define OPC_SETSELF 0xEB /* set 'self' */ 179 #define OPC_LOADCTX 0xEC /* load method context from stack */ 180 #define OPC_STORECTX 0xED /* store method context and push on stack */ 181 #define OPC_SETLCL1R0 0xEE /* set local (1-byte local number) from R0 */ 182 #define OPC_SETINDLCL1I8 0xEF /* set indexed local */ 183 184 #define OPC_BP 0xF1 /* debugger breakpoint */ 185 #define OPC_NOP 0xF2 /* no operation */ 186 187 188 #endif /* VMOP_H */ 189 190