aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h26
1 files changed, 11 insertions, 15 deletions
diff --git a/lopcodes.h b/lopcodes.h
index 627bf54e..79dae70c 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -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
158OP_JMP,/* sBx PC += sBx */ 158OP_JMP,/* sBx PC += sBx */
159 159
160OP_TESTEQ,/* A C if not (R(A) == R/K(C)) then pc++ */ 160OP_EQ,/* A B C if ((R(A) == R/K(C)) ~= B) then pc++ */
161OP_TESTNE,/* A C if not (R(A) ~= R/K(C)) then pc++ */ 161OP_CMP,/* A B C if not (R(A) <B> R/K(C)) then pc++ (see note) */
162OP_TESTLT,/* A C if not (R(A) < R/K(C)) then pc++ */
163OP_TESTLE,/* A C if not (R(A) <= R/K(C)) then pc++ */
164OP_TESTGT,/* A C if not (R(A) > R/K(C)) then pc++ */
165OP_TESTGE,/* A C if not (R(A) >= R/K(C)) then pc++ */
166 162
167OP_TESTT,/* A B if (R(B)) then R(A) := R(B) else pc++ */ 163OP_TEST,/* A B C if (R(C) <=> B) then R(A) := R(C) else pc++ */
168OP_TESTF,/* A B if not (R(B)) then R(A) := R(B) else pc++ */
169 164
170OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ 165OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
171OP_TAILCALL,/* A B return R(A)(R(A+1), ... ,R(A+B-1)) */ 166OP_TAILCALL,/* A B return R(A)(R(A+1), ... ,R(A+B-1)) */
172OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see (3)) */ 167OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
173 168
174OP_FORLOOP,/* A sBx R(A)+=R(A+2); if R(A) <?= R(A+1) then PC+= sBx */ 169OP_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/*