1 #ifndef _BYTECODE_H_
2 #define _BYTECODE_H_
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif // __cplusplus
7
8 enum
9 {
10 // SH_TYPE, // type
11 // top cmd
12 SHN3_1 = 1, // -3 1
13 SHN2_1, // -2 1
14 SHN1_2, // -1 2
15 SHN1_1, // -1 1
16 SH0_2, // 0 2
17 SH0_1, // 0 1
18 SH1_3, // 1 3
19 SH1_2, // 1 2
20 SH1_1, // 1 1
21 SH2_1, // 2 1
22 SH2_3, // 2 3
23 };
24
25 #define CMDCOUNT 235
26 #define STACK_COUNT 217
27
28 enum {
29 CNone, // 0x0, 0 Error command
30 TInt, // 0x1, 1 int type
31 TUint, // 0x2, 2 uint type
32 TByte, // 0x3, 3 byte type
33 TUbyte, // 0x4, 4 ubyte type
34 TShort, // 0x5, 5 short type
35 TUshort, // 0x6, 6 ushort type
36 TFloat, // 0x7, 7 float type
37 TDouble, // 0x8, 8 double type
38 TLong, // 0x9, 9 long type
39 TUlong, // 0xA, 10 ulong type
40 TReserved, // 0xB, 11 reserved type
41 TBuf, // 0xC, 12 buf type
42 TStr, // 0xD, 13 str type
43 TArr, // 0xE, 14 arr type
44 TCollection, // 0xF, 15 collection type
45 TAny, // 0x10, 16 any type
46 TFordata, // 0x11, 17 foreach type
47 CNop, // 0x12, 18 The command does nothing
48 CGoto, // 0x13, 19 The unconditional jump.
49 CGotonocls, // 0x14, 20 The unconditional jump without clearing stack.
50 CIfze, // 0x15, 21 The conditional jump
51 CIfznocls, // 0x16, 22 The conditional jump without clearing stack
52 CIfnze, // 0x17, 23 The conditional jump
53 CIfnznocls, // 0x18, 24 The conditional jump without clearing stack.
54 CByload, // 0x19, 25 The next ubyte push into stack. GE only
55 CShload, // 0x1A, 26 The next ushort push into stack. GE only
56 CDwload, // 0x1B, 27 The next uint push into stack.
57 CCmdload, // 0x1C, 28 The next ID push into stack.
58 CResload, // 0x1D, 29 The next ID (resource) push into stack.
59 CQwload, // 0x1E, 30 The next ulong push into stack.
60 CDwsload, // 0x1F, 31 The next uints ( cmd 1 ) ( cmd 2 ) push into the stack
61 CVarload, // 0x20, 32 Load the value of parameter or variable with number ( cmd 1)
62 CVarptrload, // 0x21, 33 Load the pointer to value of parameter or variable with number ( cmd 1)
63 CDatasize, // 0x22, 34 Load the pointer to the next data and the size
64 CLoglongtrue, // 0x23, 35 Return 1 if ulong in stack is not zero
65 CLognot, // 0x24, 36 Logical not
66 CLoglongnot, // 0x25, 37 Logical NOT for long ulong
67 CDup, // 0x26, 38 Duplicate top value
68 CDuplong, // 0x27, 39 Duplicate two top value
69 CTop, // 0x28, 40 Return the pointer to top
70 CPop, // 0x29, 41 Delete the top value
71 CGetUB, // 0x2A, 42 * ( pubyte )
72 CGetB, // 0x2B, 43 * ( pbyte )
73 CGetUS, // 0x2C, 44 * ( pushort )
74 CGetS, // 0x2D, 45 * ( pshort )
75 CGetI, // 0x2E, 46 * ( puint && pint && float )
76 CGetL, // 0x2F, 47 * ( pulong && plong && double )
77 CSetUB, // 0x30, 48 * ( pubyte ) =
78 CSetB, // 0x31, 49 * ( pbyte ) =
79 CSetUS, // 0x32, 50 * ( pushort ) =
80 CSetS, // 0x33, 51 * ( pshort ) =
81 CSetI, // 0x34, 52 * ( puint && pint && float ) =
82 CSetL, // 0x35, 53 * ( pulong && plong && double ) =
83 CAddUIUI, // 0x36, 54 +
84 CSubUIUI, // 0x37, 55 -
85 CMulUIUI, // 0x38, 56 *
86 CDivUIUI, // 0x39, 57 /
87 CModUIUI, // 0x3A, 58 %
88 CAndUIUI, // 0x3B, 59 &
89 COrUIUI, // 0x3C, 60 |
90 CXorUIUI, // 0x3D, 61 ^
91 CLeftUIUI, // 0x3E, 62 <<
92 CRightUIUI, // 0x3F, 63 >>
93 CLessUIUI, // 0x40, 64 <
94 CGreaterUIUI, // 0x41, 65 >
95 CEqUIUI, // 0x42, 66 ==
96 CNotUI, // 0x43, 67 ~
97 CIncLeftUI, // 0x44, 68 ++i
98 CIncRightUI, // 0x45, 69 i++
99 CDecLeftUI, // 0x46, 70 --i
100 CDecRightUI, // 0x47, 71 i--
101 CAddUI, // 0x48, 72 +=
102 CSubUI, // 0x49, 73 -=
103 CMulUI, // 0x4A, 74 *=
104 CDivUI, // 0x4B, 75 /=
105 CModUI, // 0x4C, 76 %=
106 CAndUI, // 0x4D, 77 &=
107 COrUI, // 0x4E, 78 |=
108 CXorUI, // 0x4F, 79 ^=
109 CLeftUI, // 0x50, 80 <<=
110 CRightUI, // 0x51, 81 >>=
111 CVarsInit, // 0x52, 82 Initialize variables in block cmd1
112 CGetText, // 0x53, 83 Get current output of text function
113 CSetText, // 0x54, 84 Print string to current output of text function
114 CPtrglobal, // 0x55, 85 Get to the global variable
115 CSubcall, // 0x56, 86 Call a subfunc cmd 1 - goto
116 CSubret, // 0x57, 87 The number of returned uint cmd 1
117 CSubpar, // 0x58, 88 Paraneters of subfunc. cmd 1 - Set block cndshift = 1
118 CSubreturn, // 0x59, 89 Return from a subfunc
119 CCmdcall, // 0x5A, 90 Call a funcion
120 CCallstd, // 0x5B, 91 Call a stdcall or cdecl funcion
121 CReturn, // 0x5C, 92 Return from the function.
122 CDbgTrace, // 0x5D, 93 Debug line tracing
123 CDbgFunc, // 0x5E, 94 Debug func entering
124 CMulII, // 0x5F, 95 *
125 CDivII, // 0x60, 96 /
126 CModII, // 0x61, 97 %
127 CLeftII, // 0x62, 98 <<
128 CRightII, // 0x63, 99 >>
129 CSignI, // 0x64, 100 change sign
130 CLessII, // 0x65, 101 <
131 CGreaterII, // 0x66, 102 >
132 CMulI, // 0x67, 103 *=
133 CDivI, // 0x68, 104 /=
134 CModI, // 0x69, 105 %=
135 CLeftI, // 0x6A, 106 <<=
136 CRightI, // 0x6B, 107 >>=
137 CMulB, // 0x6C, 108 *=
138 CDivB, // 0x6D, 109 /=
139 CModB, // 0x6E, 110 %=
140 CLeftB, // 0x6F, 111 <<=
141 CRightB, // 0x70, 112 >>=
142 CMulS, // 0x71, 113 *=
143 CDivS, // 0x72, 114 /=
144 CModS, // 0x73, 115 %=
145 CLeftS, // 0x74, 116 <<=
146 CRightS, // 0x75, 117 >>=
147 Cd2f, // 0x76, 118 double 2 float
148 Cd2i, // 0x77, 119 double 2 int
149 Cd2l, // 0x78, 120 double 2 long
150 Cf2d, // 0x79, 121 float 2 double
151 Cf2i, // 0x7A, 122 float 2 int
152 Cf2l, // 0x7B, 123 float 2 long
153 Ci2d, // 0x7C, 124 int 2 double
154 Ci2f, // 0x7D, 125 int 2 float
155 Ci2l, // 0x7E, 126 int 2 long
156 Cl2d, // 0x7F, 127 long 2 double
157 Cl2f, // 0x80, 128 long 2 float
158 Cl2i, // 0x81, 129 long 2 int
159 Cui2d, // 0x82, 130 uint 2 double
160 Cui2f, // 0x83, 131 uint 2 float
161 Cui2l, // 0x84, 132 uint 2 long
162 CAddULUL, // 0x85, 133 +
163 CSubULUL, // 0x86, 134 -
164 CMulULUL, // 0x87, 135 *
165 CDivULUL, // 0x88, 136 /
166 CModULUL, // 0x89, 137 %
167 CAndULUL, // 0x8A, 138 &
168 COrULUL, // 0x8B, 139 |
169 CXorULUL, // 0x8C, 140 ^
170 CLeftULUL, // 0x8D, 141 <<
171 CRightULUL, // 0x8E, 142 >>
172 CLessULUL, // 0x8F, 143 <
173 CGreaterULUL, // 0x90, 144 >
174 CEqULUL, // 0x91, 145 ==
175 CNotUL, // 0x92, 146 ~
176 CIncLeftUL, // 0x93, 147 ++
177 CIncRightUL, // 0x94, 148 ++
178 CDecLeftUL, // 0x95, 149 --
179 CDecRightUL, // 0x96, 150 --
180 CAddUL, // 0x97, 151 +=
181 CSubUL, // 0x98, 152 -=
182 CMulUL, // 0x99, 153 *=
183 CDivUL, // 0x9A, 154 /=
184 CModUL, // 0x9B, 155 %
185 CAndUL, // 0x9C, 156 &=
186 COrUL, // 0x9D, 157 |=
187 CXorUL, // 0x9E, 158 &=
188 CLeftUL, // 0x9F, 159 <<=
189 CRightUL, // 0xA0, 160 >>=
190 CMulLL, // 0xA1, 161 *
191 CDivLL, // 0xA2, 162 /
192 CModLL, // 0xA3, 163 %
193 CLeftLL, // 0xA4, 164 <<=
194 CRightLL, // 0xA5, 165 >>=
195 CSignL, // 0xA6, 166 sign
196 CLessLL, // 0xA7, 167 <
197 CGreaterLL, // 0xA8, 168 >
198 CMulL, // 0xA9, 169 *=
199 CDivL, // 0xAA, 170 /=
200 CModL, // 0xAB, 171 %=
201 CLeftL, // 0xAC, 172 <<=
202 CRightL, // 0xAD, 173 >>=
203 CAddFF, // 0xAE, 174 +
204 CSubFF, // 0xAF, 175 -
205 CMulFF, // 0xB0, 176 *
206 CDivFF, // 0xB1, 177 /
207 CSignF, // 0xB2, 178 sign
208 CLessFF, // 0xB3, 179 <
209 CGreaterFF, // 0xB4, 180 >
210 CEqFF, // 0xB5, 181 ==
211 CIncLeftF, // 0xB6, 182 ++
212 CIncRightF, // 0xB7, 183 ++
213 CDecLeftF, // 0xB8, 184 --
214 CDecRightF, // 0xB9, 185 --
215 CAddF, // 0xBA, 186 +=
216 CSubF, // 0xBB, 187 -=
217 CMulF, // 0xBC, 188 *=
218 CDivF, // 0xBD, 189 /=
219 CAddDD, // 0xBE, 190 +
220 CSubDD, // 0xBF, 191 -
221 CMulDD, // 0xC0, 192 *
222 CDivDD, // 0xC1, 193 /
223 CSignD, // 0xC2, 194 sign
224 CLessDD, // 0xC3, 195 <
225 CGreaterDD, // 0xC4, 196 >
226 CEqDD, // 0xC5, 197 ==
227 CIncLeftD, // 0xC6, 198 ++
228 CIncRightD, // 0xC7, 199 ++
229 CDecLeftD, // 0xC8, 200 --
230 CDecRightD, // 0xC9, 201 --
231 CAddD, // 0xCA, 202 +=
232 CSubD, // 0xCB, 203 -=
233 CMulD, // 0xCC, 204 *=
234 CDivD, // 0xCD, 205 /=
235 CIncLeftUB, // 0xCE, 206 ++
236 CIncRightUB, // 0xCF, 207 ++
237 CDecLeftUB, // 0xD0, 208 --
238 CDecRightUB, // 0xD1, 209 --
239 CAddUB, // 0xD2, 210 +=
240 CSubUB, // 0xD3, 211 -=
241 CMulUB, // 0xD4, 212 *=
242 CDivUB, // 0xD5, 213 /=
243 CModUB, // 0xD6, 214 %=
244 CAndUB, // 0xD7, 215 &=
245 COrUB, // 0xD8, 216 |=
246 CXorUB, // 0xD9, 217 ^=
247 CLeftUB, // 0xDA, 218 <<=
248 CRightUB, // 0xDB, 219 >>=
249 CIncLeftUS, // 0xDC, 220 ++
250 CIncRightUS, // 0xDD, 221 ++
251 CDecLeftUS, // 0xDE, 222 --
252 CDecRightUS, // 0xDF, 223 --
253 CAddUS, // 0xE0, 224 +=
254 CSubUS, // 0xE1, 225 -=
255 CMulUS, // 0xE2, 226 *=
256 CDivUS, // 0xE3, 227 /=
257 CModUS, // 0xE4, 228 %=
258 CAndUS, // 0xE5, 229 &=
259 COrUS, // 0xE6, 230 |=
260 CXorUS, // 0xE7, 231 ^=
261 CLeftUS, // 0xE8, 232 <<=
262 CRightUS, // 0xE9, 233 >>=
263 CCollectadd, // 0xEA, 234 Run-time loading collection
264 };
265
266
267 typedef struct CmpInfo{
268 char* name;
269 char* comment;
270 }CmpInfo;
271
272
273
274
275 extern const CmpInfo pCmpInfo[];
276 extern const ubyte shifts[];
277 extern const ubyte embtypes[];
278
279 extern const ubyte embfuncs[];
280 #define FUNCCOUNT 118
281
282 #ifdef __cplusplus
283 }
284 #endif // __cplusplus
285
286 #endif // _BYTECODE_H_