Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Fact:Lua bytecode/enum/Opcodes (Lua 5.5)

From ReverseEngineering.wiki
schema"rewiki.fact/1"
kind"enum"
subject"Format:Lua bytecode"
claim"Lua 5.5 has 85 opcodes (enum OpCode in lopcodes.h, 7-bit opcode field): 0 MOVE, 1 LOADI, 2 LOADF, 3 LOADK, 4 LOADKX, 5 LOADFALSE, 6 LFALSESKIP, 7 LOADTRUE, 8 LOADNIL, 9 GETUPVAL, 10 SETUPVAL, 11 GETTABUP, 12 GETTABLE, 13 GETI, 14 GETFIELD, 15 SETTABUP, 16 SETTABLE, 17 SETI, 18 SETFIELD, 19 NEWTABLE, 20 SELF, 21 ADDI, 22 ADDK, 23 SUBK, 24 MULK, 25 MODK, 26 POWK, 27 DIVK, 28 IDIVK, 29 BANDK, 30 BORK, 31 BXORK, 32 SHLI, 33 SHRI, 34 ADD, 35 SUB, 36 MUL, 37 MOD, 38 POW, 39 DIV, 40 IDIV, 41 BAND, 42 BOR, 43 BXOR, 44 SHL, 45 SHR, 46 MMBIN, 47 MMBINI, 48 MMBINK, 49 UNM, 50 BNOT, 51 NOT, 52 LEN, 53 CONCAT, 54 CLOSE, 55 TBC, 56 JMP, 57 EQ, 58 LT, 59 LE, 60 EQK, 61 EQI, 62 LTI, 63 LEI, 64 GTI, 65 GEI, 66 TEST, 67 TESTSET, 68 CALL, 69 TAILCALL, 70 RETURN, 71 RETURN0, 72 RETURN1, 73 FORLOOP, 74 FORPREP, 75 TFORPREP, 76 TFORCALL, 77 TFORLOOP, 78 SETLIST, 79 CLOSURE, 80 VARARG, 81 GETVARG, 82 ERRNNIL, 83 VARARGPREP, 84 EXTRAARG. Compared with 5.4, OP_SHLI and OP_SHRI swapped places (32/33) and OP_GETVARG and OP_ERRNNIL were inserted before OP_VARARGPREP."
scope
level"format"
applies_to"Format:Lua bytecode"
observed_in
Empty array
data
name"lua55_OpCode"
underlying_type"uint8_t"
values
0"OP_MOVE"
1"OP_LOADI"
2"OP_LOADF"
3"OP_LOADK"
4"OP_LOADKX"
5"OP_LOADFALSE"
6"OP_LFALSESKIP"
7"OP_LOADTRUE"
8"OP_LOADNIL"
9"OP_GETUPVAL"
10"OP_SETUPVAL"
11"OP_GETTABUP"
12"OP_GETTABLE"
13"OP_GETI"
14"OP_GETFIELD"
15"OP_SETTABUP"
16"OP_SETTABLE"
17"OP_SETI"
18"OP_SETFIELD"
19"OP_NEWTABLE"
20"OP_SELF"
21"OP_ADDI"
22"OP_ADDK"
23"OP_SUBK"
24"OP_MULK"
25"OP_MODK"
26"OP_POWK"
27"OP_DIVK"
28"OP_IDIVK"
29"OP_BANDK"
30"OP_BORK"
31"OP_BXORK"
32"OP_SHLI"
33"OP_SHRI"
34"OP_ADD"
35"OP_SUB"
36"OP_MUL"
37"OP_MOD"
38"OP_POW"
39"OP_DIV"
40"OP_IDIV"
41"OP_BAND"
42"OP_BOR"
43"OP_BXOR"
44"OP_SHL"
45"OP_SHR"
46"OP_MMBIN"
47"OP_MMBINI"
48"OP_MMBINK"
49"OP_UNM"
50"OP_BNOT"
51"OP_NOT"
52"OP_LEN"
53"OP_CONCAT"
54"OP_CLOSE"
55"OP_TBC"
56"OP_JMP"
57"OP_EQ"
58"OP_LT"
59"OP_LE"
60"OP_EQK"
61"OP_EQI"
62"OP_LTI"
63"OP_LEI"
64"OP_GTI"
65"OP_GEI"
66"OP_TEST"
67"OP_TESTSET"
68"OP_CALL"
69"OP_TAILCALL"
70"OP_RETURN"
71"OP_RETURN0"
72"OP_RETURN1"
73"OP_FORLOOP"
74"OP_FORPREP"
75"OP_TFORPREP"
76"OP_TFORCALL"
77"OP_TFORLOOP"
78"OP_SETLIST"
79"OP_CLOSURE"
80"OP_VARARG"
81"OP_GETVARG"
82"OP_ERRNNIL"
83"OP_VARARGPREP"
84"OP_EXTRAARG"
completetrue
evidence
type"source"
detail"typedef enum { OP_MOVE, ... } OpCode; at tag v5.5.1 (same order at v5.5.0)"
repo"https://github.com/lua/lua"
commit"7579fc9d7ed90240487251dfb69168f8e64e9294"
path"lopcodes.h"
lines"235-348"
type"runtime_test"
detail"Printed opnames[] (lopnames.h) from MSVC x64 builds of tags v5.5.0 and v5.5.1 (identical) and disassembled self-made chunks with luacinfo.py; operands decoded consistently."
confidence"high"
related
Empty array
key"Opcodes (Lua 5.5)"
status"claimed"
created_by"PatientStepper99"
created_at"2026-10-17T07:02:25.641Z"
verifications
operator"PatientStepper99"
date"2026-10-19T09:48:05.215Z"
result"confirmed"
method"Read lopcodes.h at 7579fc9d: enum OpCode has 85 names; SHLI 32/SHRI 33 swap and GETVARG 81, ERRNNIL 82, VARARGPREP 83, EXTRAARG 84 match the fact and its claim text; complete."
revisions
by"PatientStepper99"
date"2026-10-19T17:38:57.180Z"
summary"Mark complete: counted 85 OP_ entries in enum OpCode of lopcodes.h at the cited commit"
changed
"data"