aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-26 14:46:52 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2017-04-26 14:46:52 -0300
commit173e41b2ebed59a716d299470de25e50aee3b921 (patch)
treed106140f6940b987f28f4eaf962c2d3ab745afa1 /lopcodes.h
parenta3f9c1a77abb2add30334160055dc2ed11eb0b2e (diff)
downloadlua-173e41b2ebed59a716d299470de25e50aee3b921.tar.gz
lua-173e41b2ebed59a716d299470de25e50aee3b921.tar.bz2
lua-173e41b2ebed59a716d299470de25e50aee3b921.zip
new opcode OP_ADDI (for immediate integer operand) (Experimental)
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/lopcodes.h b/lopcodes.h
index ed3ea66d..c359581d 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.150 2017/04/20 19:53:55 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.151 2017/04/24 20:26:39 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*/
@@ -90,7 +90,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
90#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ 90#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
91 ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP)))) 91 ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
92 92
93#define getarg(i,pos,size) (cast(int, ((i)>>pos) & MASK1(size,0))) 93#define getarg(i,pos,size) (cast(int, ((i)>>(pos)) & MASK1(size,0)))
94#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ 94#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \
95 ((cast(Instruction, v)<<pos)&MASK1(size,pos)))) 95 ((cast(Instruction, v)<<pos)&MASK1(size,pos))))
96 96
@@ -100,6 +100,9 @@ enum OpMode {iABC, iABx, iAsBx, iAx}; /* basic instruction format */
100#define GETARG_B(i) getarg(i, POS_B, SIZE_B) 100#define GETARG_B(i) getarg(i, POS_B, SIZE_B)
101#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B) 101#define SETARG_B(i,v) setarg(i, v, POS_B, SIZE_B)
102 102
103#define GETARG_Br(i) getarg(i, POS_B, SIZE_B - 1)
104#define GETARG_Bk(i) getarg(i, (POS_B + SIZE_B - 1), 1)
105
103#define GETARG_C(i) getarg(i, POS_C, SIZE_C) 106#define GETARG_C(i) getarg(i, POS_C, SIZE_C)
104#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C) 107#define SETARG_C(i,v) setarg(i, v, POS_C, SIZE_C)
105 108
@@ -187,6 +190,7 @@ OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
187 190
188OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */ 191OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
189 192
193OP_ADDI,/* A B C R(A) := R(B) + C */
190OP_ADD,/* A B C R(A) := RK(B) + RK(C) */ 194OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
191OP_SUB,/* A B C R(A) := RK(B) - RK(C) */ 195OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
192OP_MUL,/* A B C R(A) := RK(B) * RK(C) */ 196OP_MUL,/* A B C R(A) := RK(B) * RK(C) */