2 ** $Id: lopcodes.h,v 1.33 1999/06/17 17:04:03 roberto Exp $
3 ** Opcodes for Lua virtual machine
4 ** See Copyright Notice in lua.h
12 ** NOTICE: variants of the same opcode must be consecutive: First, those
13 ** with word parameter, then with byte parameter.
18 /* name parm before after side effect
19 -----------------------------------------------------------------------------*/
20 ENDCODE
,/* - - (return) */
21 RETCODE
,/* b - (return) */
23 CALL
,/* b c v_c...v_1 f r_b...r_1 f(v1,...,v_c) */
25 TAILCALL
,/* b c v_c...v_1 f (return) f(v1,...,v_c) */
27 PUSHNIL
,/* b - nil_0...nil_b */
28 POP
,/* b a_b...a_1 - */
30 PUSHNUMBERW
,/* w - (float)w */
31 PUSHNUMBER
,/* b - (float)b */
33 PUSHNUMBERNEGW
,/* w - (float)-w */
34 PUSHNUMBERNEG
,/* b - (float)-b */
36 PUSHCONSTANTW
,/*w - CNST[w] */
37 PUSHCONSTANT
,/* b - CNST[b] */
39 PUSHUPVALUE
,/* b - Closure[b] */
41 PUSHLOCAL
,/* b - LOC[b] */
43 GETGLOBALW
,/* w - VAR[CNST[w]] */
44 GETGLOBAL
,/* b - VAR[CNST[b]] */
46 GETTABLE
,/* - i t t[i] */
48 GETDOTTEDW
,/* w t t[CNST[w]] */
49 GETDOTTED
,/* b t t[CNST[b]] */
51 PUSHSELFW
,/* w t t t[CNST[w]] */
52 PUSHSELF
,/* b t t t[CNST[b]] */
54 CREATEARRAYW
,/* w - newarray(size = w) */
55 CREATEARRAY
,/* b - newarray(size = b) */
57 SETLOCAL
,/* b x - LOC[b]=x */
59 SETGLOBALW
,/* w x - VAR[CNST[w]]=x */
60 SETGLOBAL
,/* b x - VAR[CNST[b]]=x */
62 SETTABLEPOP
,/* - v i t - t[i]=v */
64 SETTABLE
,/* b v a_b...a_1 i t a_b...a_1 i t t[i]=v */
66 SETLISTW
,/* w c v_c...v_1 t t t[i+w*FPF]=v_i */
67 SETLIST
,/* b c v_c...v_1 t t t[i+b*FPF]=v_i */
69 SETMAP
,/* b v_b k_b ...v_0 k_0 t t t[k_i]=v_i */
71 NEQOP
,/* - y x (x~=y)? 1 : nil */
72 EQOP
,/* - y x (x==y)? 1 : nil */
73 LTOP
,/* - y x (x<y)? 1 : nil */
74 LEOP
,/* - y x (x<y)? 1 : nil */
75 GTOP
,/* - y x (x>y)? 1 : nil */
76 GEOP
,/* - y x (x>=y)? 1 : nil */
79 MULTOP
,/* - y x x*y */
82 CONCOP
,/* - y x x..y */
84 NOTOP
,/* - x (x==nil)? 1 : nil */
86 ONTJMPW
,/* w x (x!=nil)? x : - (x!=nil)? PC+=w */
87 ONTJMP
,/* b x (x!=nil)? x : - (x!=nil)? PC+=b */
88 ONFJMPW
,/* w x (x==nil)? x : - (x==nil)? PC+=w */
89 ONFJMP
,/* b x (x==nil)? x : - (x==nil)? PC+=b */
90 JMPW
,/* w - - PC+=w */
92 IFFJMPW
,/* w x - (x==nil)? PC+=w */
93 IFFJMP
,/* b x - (x==nil)? PC+=b */
94 IFTUPJMPW
,/* w x - (x!=nil)? PC-=w */
95 IFTUPJMP
,/* b x - (x!=nil)? PC-=b */
96 IFFUPJMPW
,/* w x - (x==nil)? PC-=w */
97 IFFUPJMP
,/* b x - (x==nil)? PC-=b */
99 CLOSUREW
,/* w c v_c...v_1 closure(CNST[w], v_c...v_1) */
100 CLOSURE
,/* b c v_c...v_1 closure(CNST[b], v_c...v_1) */
102 SETLINEW
,/* w - - LINE=w */
103 SETLINE
,/* b - - LINE=b */
105 LONGARGW
,/* w (add w*(1<<16) to arg of next instruction) */
106 LONGARG
,/* b (add b*(1<<16) to arg of next instruction) */
108 CHECKSTACK
/* b (assert #temporaries == b; only for internal debuging!) */
113 #define RFIELDS_PER_FLUSH 32 /* records (SETMAP) */
114 #define LFIELDS_PER_FLUSH 64 /* FPF - lists (SETLIST) */
116 #define ZEROVARARG 128
119 /* maximum value of an arg of 3 bytes; must fit in an "int" */
120 #if MAX_INT < (1<<24)
121 #define MAX_ARG MAX_INT
123 #define MAX_ARG ((1<<24)-1)
126 /* maximum value of a word of 2 bytes; cannot be bigger than MAX_ARG */
127 #if MAX_ARG < (1<<16)
128 #define MAX_WORD MAX_ARG
130 #define MAX_WORD ((1<<16)-1)
134 /* maximum value of a byte */
135 #define MAX_BYTE ((1<<8)-1)