diff options
Diffstat (limited to 'lopcodes.h')
-rw-r--r-- | lopcodes.h | 30 |
1 files changed, 18 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.170 2017/11/22 19:15:44 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.171 2017/11/27 17:44:31 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -114,13 +114,15 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */ | |||
114 | #define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A) | 114 | #define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A) |
115 | 115 | ||
116 | #define GETARG_B(i) check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B)) | 116 | #define GETARG_B(i) check_exp(checkopm(i, iABC), getarg(i, POS_B, SIZE_B)) |
117 | #define GETARG_sB(i) (GETARG_B(i) - MAXARG_sC) | ||
117 | #define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B) | 118 | #define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B) |
118 | 119 | ||
119 | #define GETARG_C(i) check_exp(checkopm(i, iABC), getarg(i, POS_C, SIZE_C)) | 120 | #define GETARG_C(i) check_exp(checkopm(i, iABC), getarg(i, POS_C, SIZE_C)) |
120 | #define GETARG_sC(i) (GETARG_C(i) - MAXARG_sC) | 121 | #define GETARG_sC(i) (GETARG_C(i) - MAXARG_sC) |
121 | #define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) | 122 | #define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) |
122 | 123 | ||
123 | #define GETARG_k(i) (cast(int, ((i) & (1 << POS_k)))) | 124 | #define TESTARG_k(i) (cast(int, ((i) & (1 << POS_k)))) |
125 | #define GETARG_k(i) getarg(i, POS_k, 1) | ||
124 | #define SETARG_k(i,v) setarg(i, v, POS_k, 1) | 126 | #define SETARG_k(i,v) setarg(i, v, POS_k, 1) |
125 | 127 | ||
126 | #define GETARG_Bx(i) check_exp(checkopm(i, iABx), getarg(i, POS_Bx, SIZE_Bx)) | 128 | #define GETARG_Bx(i) check_exp(checkopm(i, iABx), getarg(i, POS_Bx, SIZE_Bx)) |
@@ -236,17 +238,17 @@ OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ | |||
236 | 238 | ||
237 | OP_CLOSE,/* A close all upvalues >= R(A) */ | 239 | OP_CLOSE,/* A close all upvalues >= R(A) */ |
238 | OP_JMP,/* k sJ pc += sJ (k is used in code generation) */ | 240 | OP_JMP,/* k sJ pc += sJ (k is used in code generation) */ |
239 | OP_EQ,/* A B C if ((R(A) == R(C)) ~= B) then pc++ */ | 241 | OP_EQ,/* A B if ((R(A) == R(B)) ~= k) then pc++ */ |
240 | OP_LT,/* A B C if ((R(A) < R(C)) ~= B) then pc++ */ | 242 | OP_LT,/* A B if ((R(A) < R(B)) ~= k) then pc++ */ |
241 | OP_LE,/* A B C if ((R(A) <= R(C)) ~= B) then pc++ */ | 243 | OP_LE,/* A B if ((R(A) <= R(B)) ~= k) then pc++ */ |
242 | 244 | ||
243 | OP_EQK,/* A B C if ((R(A) == K(C)) ~= B) then pc++ */ | 245 | OP_EQK,/* A B if ((R(A) == K(B)) ~= k) then pc++ */ |
244 | OP_EQI,/* A B C if ((R(A) == C) ~= B) then pc++ */ | 246 | OP_EQI,/* A sB if ((R(A) == sB) ~= k) then pc++ */ |
245 | OP_LTI,/* A B C if ((R(A) < C) ~= B) then pc++ */ | 247 | OP_LTI,/* A sB if ((R(A) < sB) ~= k) then pc++ */ |
246 | OP_LEI,/* A B C if ((R(A) <= C) ~= B) then pc++ */ | 248 | OP_LEI,/* A sB if ((R(A) <= sB) ~= k) then pc++ */ |
247 | 249 | ||
248 | OP_TEST,/* A C if not (R(A) <=> C) then pc++ */ | 250 | OP_TEST,/* A if (not R(A) == k) then pc++ */ |
249 | OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */ | 251 | OP_TESTSET,/* A B if (not R(B) == k) then R(A) := R(B) else pc++ */ |
250 | 252 | ||
251 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ | 253 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ |
252 | OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ | 254 | OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ |
@@ -289,9 +291,13 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
289 | 291 | ||
290 | (*) In OP_LOADKX, the next 'instruction' is always EXTRAARG. | 292 | (*) In OP_LOADKX, the next 'instruction' is always EXTRAARG. |
291 | 293 | ||
292 | (*) For comparisons, A specifies what condition the test should accept | 294 | (*) For comparisons, k specifies what condition the test should accept |
293 | (true or false). | 295 | (true or false). |
294 | 296 | ||
297 | (*) For OP_LTI/OP_LEI, C indicates that the transformations | ||
298 | (A<B) => (!(B<=A)) or (A<=B) => (!(B<A)) were used to put the | ||
299 | constant operator on the right side. | ||
300 | |||
295 | (*) All 'skips' (pc++) assume that next instruction is a jump. | 301 | (*) All 'skips' (pc++) assume that next instruction is a jump. |
296 | 302 | ||
297 | ===========================================================================*/ | 303 | ===========================================================================*/ |