summaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-08-04 17:18:13 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-08-04 17:18:13 -0300
commit6bddbbde7aaedbea2d5240964dc544f801655941 (patch)
treef5af79485f2433b57a1a9dc21124b5b8f91483d4 /lopcodes.h
parent31e48f26ed449ecfea88241106da98f66f00b9c0 (diff)
downloadlua-6bddbbde7aaedbea2d5240964dc544f801655941.tar.gz
lua-6bddbbde7aaedbea2d5240964dc544f801655941.tar.bz2
lua-6bddbbde7aaedbea2d5240964dc544f801655941.zip
details (opcode may not be the first field)
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/lopcodes.h b/lopcodes.h
index c9225c5c..697eb5d6 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.109 2004/05/31 18:51:50 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.110 2004/06/29 18:49:02 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*/
@@ -41,10 +41,11 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
41 41
42#define SIZE_OP 6 42#define SIZE_OP 6
43 43
44#define POS_OP 0
45#define POS_A (POS_OP + SIZE_OP)
44#define POS_C (POS_A + SIZE_A) 46#define POS_C (POS_A + SIZE_A)
45#define POS_B (POS_C + SIZE_C) 47#define POS_B (POS_C + SIZE_C)
46#define POS_Bx POS_C 48#define POS_Bx POS_C
47#define POS_A SIZE_OP
48 49
49 50
50/* 51/*
@@ -76,8 +77,9 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
76** the following macros help to manipulate instructions 77** the following macros help to manipulate instructions
77*/ 78*/
78 79
79#define GET_OPCODE(i) (cast(OpCode, (i)&MASK1(SIZE_OP,0))) 80#define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
80#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,0)) | cast(Instruction, o))) 81#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
82 ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))
81 83
82#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0))) 84#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
83#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ 85#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
@@ -99,12 +101,12 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
99#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx)) 101#define SETARG_sBx(i,b) SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
100 102
101 103
102#define CREATE_ABC(o,a,b,c) (cast(Instruction, o) \ 104#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
103 | (cast(Instruction, a)<<POS_A) \ 105 | (cast(Instruction, a)<<POS_A) \
104 | (cast(Instruction, b)<<POS_B) \ 106 | (cast(Instruction, b)<<POS_B) \
105 | (cast(Instruction, c)<<POS_C)) 107 | (cast(Instruction, c)<<POS_C))
106 108
107#define CREATE_ABx(o,a,bc) (cast(Instruction, o) \ 109#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
108 | (cast(Instruction, a)<<POS_A) \ 110 | (cast(Instruction, a)<<POS_A) \
109 | (cast(Instruction, bc)<<POS_Bx)) 111 | (cast(Instruction, bc)<<POS_Bx))
110 112