diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-06 12:51:41 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-05-06 12:51:41 -0300 |
| commit | 0dbf0c5953a3d72deebc7e41840a0e73b46de8bc (patch) | |
| tree | b4a525660cba017d7985c37393f50d6b8bee9e4b /lopcodes.h | |
| parent | 85dcb411a8454de0bc1c2c60a24af1588e436c23 (diff) | |
| download | lua-0dbf0c5953a3d72deebc7e41840a0e73b46de8bc.tar.gz lua-0dbf0c5953a3d72deebc7e41840a0e73b46de8bc.tar.bz2 lua-0dbf0c5953a3d72deebc7e41840a0e73b46de8bc.zip | |
new format for test intructions (handle NaN correctly)
Diffstat (limited to 'lopcodes.h')
| -rw-r--r-- | lopcodes.h | 26 |
1 files changed, 11 insertions, 15 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.h,v 1.94 2002/04/09 19:47:44 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.95 2002/04/24 20:07:46 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 | */ |
| @@ -81,19 +81,19 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ | |||
| 81 | 81 | ||
| 82 | #define GETARG_A(i) (cast(int, (i)>>POS_A)) | 82 | #define GETARG_A(i) (cast(int, (i)>>POS_A)) |
| 83 | #define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ | 83 | #define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ |
| 84 | (cast(Instruction, u)<<POS_A))) | 84 | ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A)))) |
| 85 | 85 | ||
| 86 | #define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0))) | 86 | #define GETARG_B(i) (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0))) |
| 87 | #define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ | 87 | #define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \ |
| 88 | (cast(Instruction, b)<<POS_B))) | 88 | ((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B)))) |
| 89 | 89 | ||
| 90 | #define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0))) | 90 | #define GETARG_C(i) (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0))) |
| 91 | #define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ | 91 | #define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \ |
| 92 | (cast(Instruction, b)<<POS_C))) | 92 | ((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C)))) |
| 93 | 93 | ||
| 94 | #define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0))) | 94 | #define GETARG_Bx(i) (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0))) |
| 95 | #define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ | 95 | #define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \ |
| 96 | (cast(Instruction, b)<<POS_Bx))) | 96 | ((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx)))) |
| 97 | 97 | ||
| 98 | #define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx) | 98 | #define GETARG_sBx(i) (GETARG_Bx(i)-MAXARG_sBx) |
| 99 | #define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx)) | 99 | #define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx)) |
| @@ -157,19 +157,14 @@ OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */ | |||
| 157 | 157 | ||
| 158 | OP_JMP,/* sBx PC += sBx */ | 158 | OP_JMP,/* sBx PC += sBx */ |
| 159 | 159 | ||
| 160 | OP_TESTEQ,/* A C if not (R(A) == R/K(C)) then pc++ */ | 160 | OP_EQ,/* A B C if ((R(A) == R/K(C)) ~= B) then pc++ */ |
| 161 | OP_TESTNE,/* A C if not (R(A) ~= R/K(C)) then pc++ */ | 161 | OP_CMP,/* A B C if not (R(A) <B> R/K(C)) then pc++ (see note) */ |
| 162 | OP_TESTLT,/* A C if not (R(A) < R/K(C)) then pc++ */ | ||
| 163 | OP_TESTLE,/* A C if not (R(A) <= R/K(C)) then pc++ */ | ||
| 164 | OP_TESTGT,/* A C if not (R(A) > R/K(C)) then pc++ */ | ||
| 165 | OP_TESTGE,/* A C if not (R(A) >= R/K(C)) then pc++ */ | ||
| 166 | 162 | ||
| 167 | OP_TESTT,/* A B if (R(B)) then R(A) := R(B) else pc++ */ | 163 | OP_TEST,/* A B C if (R(C) <=> B) then R(A) := R(C) else pc++ */ |
| 168 | OP_TESTF,/* A B if not (R(B)) then R(A) := R(B) else pc++ */ | ||
| 169 | 164 | ||
| 170 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ | 165 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ |
| 171 | OP_TAILCALL,/* A B return R(A)(R(A+1), ... ,R(A+B-1)) */ | 166 | OP_TAILCALL,/* A B return R(A)(R(A+1), ... ,R(A+B-1)) */ |
| 172 | OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see (3)) */ | 167 | OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */ |
| 173 | 168 | ||
| 174 | OP_FORLOOP,/* A sBx R(A)+=R(A+2); if R(A) <?= R(A+1) then PC+= sBx */ | 169 | OP_FORLOOP,/* A sBx R(A)+=R(A+2); if R(A) <?= R(A+1) then PC+= sBx */ |
| 175 | 170 | ||
| @@ -196,8 +191,9 @@ OP_CLOSURE/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ | |||
| 196 | next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. | 191 | next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. |
| 197 | 192 | ||
| 198 | (2) In OP_RETURN, if (B == 0) then return up to `top' | 193 | (2) In OP_RETURN, if (B == 0) then return up to `top' |
| 199 | ===========================================================================*/ | ||
| 200 | 194 | ||
| 195 | (3) For comparisons, B specifies what conditions the test should accept. | ||
| 196 | ===========================================================================*/ | ||
| 201 | 197 | ||
| 202 | 198 | ||
| 203 | /* | 199 | /* |
