Debian Codegraph @

terps/tads/tads3/vmop.h

raw symbols SCIP
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 /*
24 * T3 VM opcode definitions
25 */
26 class CVmOpcodes
27 {
28 public:
29 /*
30 * Opcode size table. Index by opcode; each entry gives the size in
31 * bytes of the instruction. A value of 0 is special - it means that
32 * the instruction is varying-length.
33 */
34 static const uchar op_siz[];
35
36 /*
37 * Get the size in bytes of an opcode. This computes the actual size
38 * of varying-length instructions.
39 */
40 static size_t get_op_size(const uchar *op);
41 };
42
43
44 #define OPC_PUSH_0 0x01 /* push constant integer 0 */
45 #define OPC_PUSH_1 0x02 /* push constant integer 1 */
46 #define OPC_PUSHINT8 0x03 /* push SBYTE operand as integer */
47 #define OPC_PUSHINT 0x04 /* push INT4 operand as integer */
48 #define OPC_PUSHSTR 0x05 /* push UINT4 operand as string constant */
49 #define OPC_PUSHLST 0x06 /* push UINT4 operand as list constant */
50 #define OPC_PUSHOBJ 0x07 /* push UINT4 operand as object ID */
51 #define OPC_PUSHNIL 0x08 /* push nil */
52 #define OPC_PUSHTRUE 0x09 /* push true */
53 #define OPC_PUSHPROPID 0x0A /* push UINT2 operand as property ID */
54 #define OPC_PUSHFNPTR 0x0B /* push UINT4 code offset */
55 #define OPC_PUSHSTRI 0x0C /* push inline string constant */
56 #define OPC_PUSHPARLST 0x0D /* push varargs parameter list */
57 #define OPC_MAKELSTPAR 0x0E /* push varargs parameter from list */
58 #define OPC_PUSHENUM 0x0F /* push an enum value */
59 #define OPC_PUSHBIFPTR 0x10 /* push a pointer to a built-in function */
60
61 #define OPC_NEG 0x20 /* negate */
62 #define OPC_BNOT 0x21 /* bitwise NOT */
63 #define OPC_ADD 0x22 /* add */
64 #define OPC_SUB 0x23 /* subtract */
65 #define OPC_MUL 0x24 /* multiply */
66 #define OPC_BAND 0x25 /* bitwise AND */
67 #define OPC_BOR 0x26 /* bitwise OR */
68 #define OPC_SHL 0x27 /* shift left */
69 #define OPC_ASHR 0x28 /* arithmetic shift right */
70 #define OPC_XOR 0x29 /* bitwise/logical XOR */
71 #define OPC_DIV 0x2A /* divide */
72 #define OPC_MOD 0x2B /* MOD (remainder) */
73 #define OPC_NOT 0x2C /* logical NOT */
74 #define OPC_BOOLIZE 0x2D /* convert top of stack to true/nil */
75 #define OPC_INC 0x2E /* increment value at top of stack */
76 #define OPC_DEC 0x2F /* decrement value at top of stack */
77 #define OPC_LSHR 0x30 /* logical shift right */
78
79 #define OPC_EQ 0x40 /* equals */
80 #define OPC_NE 0x41 /* not equals */
81 #define OPC_LT 0x42 /* less than */
82 #define OPC_LE 0x43 /* less than or equal to */
83 #define OPC_GT 0x44 /* greater than */
84 #define OPC_GE 0x45 /* greater than or equal to */
85
86 #define OPC_RETVAL 0x50 /* return with value at top of stack */
87 #define OPC_RETNIL 0x51 /* return nil */
88 #define OPC_RETTRUE 0x52 /* return true */
89 #define OPC_RET 0x54 /* return with no value */
90
91 #define OPC_NAMEDARGPTR 0x56 /* pointer to named argument table */
92 #define OPC_NAMEDARGTAB 0x57 /* named argument table */
93
94 #define OPC_CALL 0x58 /* function call */
95 #define OPC_PTRCALL 0x59 /* function call through pointer */
96
97 #define OPC_GETPROP 0x60 /* get property */
98 #define OPC_CALLPROP 0x61 /* call property with arguments */
99 #define OPC_PTRCALLPROP 0x62 /* call property through pointer with args */
100 #define OPC_GETPROPSELF 0x63 /* get property of 'self' */
101 #define OPC_CALLPROPSELF 0x64 /* call method of 'self' */
102 #define OPC_PTRCALLPROPSELF 0x65 /* call method of 'self' through pointer */
103 #define OPC_OBJGETPROP 0x66 /* get property of specific object */
104 #define OPC_OBJCALLPROP 0x67 /* call method of specific object */
105 #define OPC_GETPROPDATA 0x68 /* get property, disallowing side effects */
106 #define OPC_PTRGETPROPDATA 0x69 /* get prop through pointer, data only */
107 #define OPC_GETPROPLCL1 0x6A /* get property of local variable */
108 #define OPC_CALLPROPLCL1 0x6B /* call property of local variable */
109 #define OPC_GETPROPR0 0x6C /* get property of R0 */
110 #define OPC_CALLPROPR0 0x6D /* call property of R0 */
111
112 #define OPC_INHERIT 0x72 /* inherit from superclass */
113 #define OPC_PTRINHERIT 0x73 /* inherit through property pointer */
114 #define OPC_EXPINHERIT 0x74 /* inherit from an explicit superclass */
115 #define OPC_PTREXPINHERIT 0x75 /* inherit from explicit sc through prop ptr */
116 #define OPC_VARARGC 0x76 /* modifier: next call is var arg count */
117 #define OPC_DELEGATE 0x77 /* delegate to object on stack */
118 #define OPC_PTRDELEGATE 0x78 /* delegate through property pointer */
119
120 #define OPC_SWAP2 0x7A /* swap top two elements with next two */
121 #define OPC_SWAPN 0x7B /* swap elements at operand indices */
122
123 #define OPC_GETARGN0 0x7C /* get argument #0 */
124 #define OPC_GETARGN1 0x7D /* get argument #1 */
125 #define OPC_GETARGN2 0x7E /* get argument #2 */
126 #define OPC_GETARGN3 0x7F /* get argument #3 */
127
128 #define OPC_GETLCL1 0x80 /* push a local variable */
129 #define OPC_GETLCL2 0x81 /* push a local (2-byte index) */
130 #define OPC_GETARG1 0x82 /* push an argument */
131 #define OPC_GETARG2 0x83 /* push an argument (2-byte index) */
132 #define OPC_PUSHSELF 0x84 /* push 'self' */
133 #define OPC_GETDBLCL 0x85 /* push debug frame local */
134 #define OPC_GETDBARG 0x86 /* push debug frame argument */
135 #define OPC_GETARGC 0x87 /* get current argument count */
136 #define OPC_DUP 0x88 /* duplicate top of stack */
137 #define OPC_DISC 0x89 /* discard top of stack */
138 #define OPC_DISC1 0x8A /* discard n items from stack */
139 #define OPC_GETR0 0x8B /* push the R0 register onto the stack */
140 #define OPC_GETDBARGC 0x8C /* push debug frame argument count */
141 #define OPC_SWAP 0x8D /* swap top two stack elements */
142
143 #define OPC_PUSHCTXELE 0x8E /* push a method context value */
144 #define PUSHCTXELE_TARGPROP 0x01 /* push target property */
145 #define PUSHCTXELE_TARGOBJ 0x02 /* push target object */
146 #define PUSHCTXELE_DEFOBJ 0x03 /* push defining object */
147 #define PUSHCTXELE_INVOKEE 0x04 /* push the invokee */
148
149 #define OPC_DUP2 0x8F /* duplicate the top two stack elements */
150
151 #define OPC_SWITCH 0x90 /* jump through case table */
152 #define OPC_JMP 0x91 /* unconditional branch */
153 #define OPC_JT 0x92 /* jump if true */
154 #define OPC_JF 0x93 /* jump if false */
155 #define OPC_JE 0x94 /* jump if equal */
156 #define OPC_JNE 0x95 /* jump if not equal */
157 #define OPC_JGT 0x96 /* jump if greater than */
158 #define OPC_JGE 0x97 /* jump if greater or equal */
159 #define OPC_JLT 0x98 /* jump if less than */
160 #define OPC_JLE 0x99 /* jump if less than or equal */
161 #define OPC_JST 0x9A /* jump and save if true */
162 #define OPC_JSF 0x9B /* jump and save if false */
163 #define OPC_LJSR 0x9C /* local jump to subroutine */
164 #define OPC_LRET 0x9D /* local return from subroutine */
165 #define OPC_JNIL 0x9E /* jump if nil */
166 #define OPC_JNOTNIL 0x9F /* jump if not nil */
167 #define OPC_JR0T 0xA0 /* jump if R0 is true */
168 #define OPC_JR0F 0xA1 /* jump if R0 is false */
169 #define OPC_ITERNEXT 0xA2 /* iterator next */
170
171 #define OPC_GETSETLCL1R0 0xA3 /* set local from R0 and leave value on stack */
172 #define OPC_GETSETLCL1 0xA4 /* set local and leave value on stack */
173 #define OPC_DUPR0 0xA5 /* push R0 twice */
174 #define OPC_GETSPN 0xA6 /* get stack element at given index */
175
176 #define OPC_GETLCLN0 0xAA /* get local #0 */
177 #define OPC_GETLCLN1 0xAB /* get local #1 */
178 #define OPC_GETLCLN2 0xAC /* get local #2 */
179 #define OPC_GETLCLN3 0xAD /* get local #3 */
180 #define OPC_GETLCLN4 0xAE /* get local #4 */
181 #define OPC_GETLCLN5 0xAF /* get local #5 */
182
183 #define OPC_SAY 0xB0 /* display a constant string */
184 #define OPC_BUILTIN_A 0xB1 /* call built-in func from set 0 */
185 #define OPC_BUILTIN_B 0xB2 /* call built-in from set 1 */
186 #define OPC_BUILTIN_C 0xB3 /* call built-in from set 2 */
187 #define OPC_BUILTIN_D 0xB4 /* call built-in from set 3 */
188 #define OPC_BUILTIN1 0xB5 /* call built-in from any set, 8-bit index */
189 #define OPC_BUILTIN2 0xB6 /* call built-in from any set, 16-bit index */
190 #define OPC_CALLEXT 0xB7 /* call external function */
191 #define OPC_THROW 0xB8 /* throw an exception */
192 #define OPC_SAYVAL 0xB9 /* display the value at top of stack */
193
194 #define OPC_INDEX 0xBA /* index a list */
195 #define OPC_IDXLCL1INT8 0xBB /* index a local variable by an int8 value */
196 #define OPC_IDXINT8 0xBC /* index by an int8 value */
197
198 #define OPC_NEW1 0xC0 /* create new object instance */
199 #define OPC_NEW2 0xC1 /* create new object (2-byte operands) */
200 #define OPC_TRNEW1 0xC2 /* create new transient instance */
201 #define OPC_TRNEW2 0xC3 /* create transient object (2-byte operands) */
202
203 #define OPC_INCLCL 0xD0 /* increment local variable by 1 */
204 #define OPC_DECLCL 0xD1 /* decrement local variable by 1 */
205 #define OPC_ADDILCL1 0xD2 /* add immediate 1-byte int to local */
206 #define OPC_ADDILCL4 0xD3 /* add immediate 4-byte int to local */
207 #define OPC_ADDTOLCL 0xD4 /* add value to local variable */
208 #define OPC_SUBFROMLCL 0xD5 /* subtract value from local variable */
209 #define OPC_ZEROLCL1 0xD6 /* set local to zero */
210 #define OPC_ZEROLCL2 0xD7 /* set local to zero */
211 #define OPC_NILLCL1 0xD8 /* set local to nil */
212 #define OPC_NILLCL2 0xD9 /* set local to nil */
213 #define OPC_ONELCL1 0xDA /* set local to numeric value 1 */
214 #define OPC_ONELCL2 0xDB /* set local to numeric value 1 */
215
216 #define OPC_SETLCL1 0xE0 /* set local (1-byte local number) */
217 #define OPC_SETLCL2 0xE1 /* set local (2-byte local number) */
218 #define OPC_SETARG1 0xE2 /* set parameter (1-byte param number) */
219 #define OPC_SETARG2 0xE3 /* set parameter (2-byte param number) */
220 #define OPC_SETIND 0xE4 /* set value at index */
221 #define OPC_SETPROP 0xE5 /* set property in object */
222 #define OPC_PTRSETPROP 0xE6 /* set property through prop pointer */
223 #define OPC_SETPROPSELF 0xE7 /* set property in self */
224 #define OPC_OBJSETPROP 0xE8 /* set property in immediate object */
225 #define OPC_SETDBLCL 0xE9 /* set debugger local variable */
226 #define OPC_SETDBARG 0xEA /* set debugger parameter variable */
227
228 #define OPC_SETSELF 0xEB /* set 'self' */
229 #define OPC_LOADCTX 0xEC /* load method context from stack */
230 #define OPC_STORECTX 0xED /* store method context and push on stack */
231 #define OPC_SETLCL1R0 0xEE /* set local (1-byte local number) from R0 */
232 #define OPC_SETINDLCL1I8 0xEF /* set indexed local */
233
234 #define OPC_BP 0xF1 /* debugger breakpoint */
235 #define OPC_NOP 0xF2 /* no operation */
236
237
238 #endif /* VMOP_H */
239