Rizin
unix-like reverse engineering framework and cli tools
opcode_54.c
Go to the documentation of this file.
1
// SPDX-License-Identifier: LGPL-3.0-only
2
// SPDX-FileCopyrightText: 2021 Heersin <teablearcher@gmail.com>
3
4
#include "
arch_54.h
"
5
#define lua_strcase(case_str) if ( \
6
((limit) <= sizeof(case_str) - 1) && \
7
rz_str_ncasecmp((name), (case_str), sizeof(case_str) - 1) == 0)
8
9
LuaOpNameList
get_lua54_opnames
(
void
) {
10
LuaOpNameList
list
=
RZ_NEWS
(
char
*,
LUA_NUM_OPCODES
+ 1);
11
if
(
list
==
NULL
) {
12
RZ_LOG_ERROR
(
"Cannot allocate lua54 opcode list.\n"
);
13
return
NULL
;
14
}
15
16
// Do not free the const string
17
list
[
OP_MOVE
] =
"move"
;
18
list
[
OP_LOADI
] =
"loadi"
,
19
list
[
OP_LOADF
] =
"loadf"
,
20
list
[
OP_LOADK
] =
"loadk"
,
21
list
[
OP_LOADKX
] =
"loadkx"
,
22
list
[
OP_LOADFALSE
] =
"loadfalse"
,
23
list
[
OP_LFALSESKIP
] =
"lfalseskip"
,
24
list
[
OP_LOADTRUE
] =
"loadtrue"
,
25
list
[
OP_LOADNIL
] =
"loadnil"
,
26
list
[
OP_GETUPVAL
] =
"getupval"
,
27
list
[
OP_SETUPVAL
] =
"setupval"
,
28
list
[
OP_GETTABUP
] =
"gettabup"
,
29
list
[
OP_GETTABLE
] =
"gettable"
,
30
list
[
OP_GETI
] =
"geti"
,
31
list
[
OP_GETFIELD
] =
"getfield"
,
32
list
[
OP_SETTABUP
] =
"settabup"
,
33
list
[
OP_SETTABLE
] =
"settable"
,
34
list
[
OP_SETI
] =
"seti"
,
35
list
[
OP_SETFIELD
] =
"setfield"
,
36
list
[
OP_NEWTABLE
] =
"newtable"
,
37
list
[
OP_SELF
] =
"self"
,
38
list
[
OP_ADDI
] =
"addi"
,
39
list
[
OP_ADDK
] =
"addk"
,
40
list
[
OP_SUBK
] =
"subk"
,
41
list
[
OP_MULK
] =
"mulk"
,
42
list
[
OP_MODK
] =
"modk"
,
43
list
[
OP_POWK
] =
"powk"
,
44
list
[
OP_DIVK
] =
"divk"
,
45
list
[
OP_IDIVK
] =
"idivk"
,
46
list
[
OP_BANDK
] =
"bandk"
,
47
list
[
OP_BORK
] =
"bork"
,
48
list
[
OP_BXORK
] =
"bxork"
,
49
list
[
OP_SHRI
] =
"shri"
,
50
list
[
OP_SHLI
] =
"shli"
,
51
list
[
OP_ADD
] =
"add"
,
52
list
[
OP_SUB
] =
"sub"
,
53
list
[
OP_MUL
] =
"mul"
,
54
list
[
OP_MOD
] =
"mod"
,
55
list
[
OP_POW
] =
"pow"
,
56
list
[
OP_DIV
] =
"div"
,
57
list
[
OP_IDIV
] =
"idiv"
,
58
list
[
OP_BAND
] =
"band"
,
59
list
[
OP_BOR
] =
"bor"
,
60
list
[
OP_BXOR
] =
"bxor"
,
61
list
[
OP_SHL
] =
"shl"
,
62
list
[
OP_SHR
] =
"shr"
,
63
list
[
OP_MMBIN
] =
"mmbin"
,
64
list
[
OP_MMBINI
] =
"mmbini"
,
65
list
[
OP_MMBINK
] =
"mmbink"
,
66
list
[
OP_UNM
] =
"unm"
,
67
list
[
OP_BNOT
] =
"bnot"
,
68
list
[
OP_NOT
] =
"not"
,
69
list
[
OP_LEN
] =
"len"
,
70
list
[
OP_CONCAT
] =
"concat"
,
71
list
[
OP_CLOSE
] =
"close"
,
72
list
[
OP_TBC
] =
"tbc"
,
73
list
[
OP_JMP
] =
"jmp"
,
74
list
[
OP_EQ
] =
"eq"
,
75
list
[
OP_LT
] =
"lt"
,
76
list
[
OP_LE
] =
"le"
,
77
list
[
OP_EQK
] =
"eqk"
,
78
list
[
OP_EQI
] =
"eqi"
,
79
list
[
OP_LTI
] =
"lti"
,
80
list
[
OP_LEI
] =
"lei"
,
81
list
[
OP_GTI
] =
"gti"
,
82
list
[
OP_GEI
] =
"gei"
,
83
list
[
OP_TEST
] =
"test"
,
84
list
[
OP_TESTSET
] =
"testset"
,
85
list
[
OP_CALL
] =
"call"
,
86
list
[
OP_TAILCALL
] =
"tailcall"
,
87
list
[
OP_RETURN
] =
"return"
,
88
list
[
OP_RETURN0
] =
"return0"
,
89
list
[
OP_RETURN1
] =
"return1"
,
90
list
[
OP_FORLOOP
] =
"forloop"
,
91
list
[
OP_FORPREP
] =
"forprep"
,
92
list
[
OP_TFORPREP
] =
"tforprep"
,
93
list
[
OP_TFORCALL
] =
"tforcall"
,
94
list
[
OP_TFORLOOP
] =
"tforloop"
,
95
list
[
OP_SETLIST
] =
"setlist"
,
96
list
[
OP_CLOSURE
] =
"closure"
,
97
list
[
OP_VARARG
] =
"vararg"
,
98
list
[
OP_VARARGPREP
] =
"varargprep"
,
99
list
[
OP_EXTRAARG
] =
"extraarg"
,
100
list
[
LUA_NUM_OPCODES
] =
NULL
;
101
102
return
list
;
103
}
104
105
ut8
get_lua54_opcode_by_name
(
const
char
*
name
,
int
limit
) {
106
lua_strcase
(
"move"
)
return
OP_MOVE
;
107
lua_strcase
(
"loadi"
)
return
OP_LOADI
;
108
lua_strcase
(
"loadf"
)
return
OP_LOADF
;
109
lua_strcase
(
"loadk"
)
return
OP_LOADK
;
110
lua_strcase
(
"loadkx"
)
return
OP_LOADKX
;
111
lua_strcase
(
"loadfalse"
)
return
OP_LOADFALSE
;
112
lua_strcase
(
"lfalseskip"
)
return
OP_LFALSESKIP
;
113
lua_strcase
(
"loadtrue"
)
return
OP_LOADTRUE
;
114
lua_strcase
(
"loadnil"
)
return
OP_LOADNIL
;
115
lua_strcase
(
"getupval"
)
return
OP_GETUPVAL
;
116
lua_strcase
(
"setupval"
)
return
OP_SETUPVAL
;
117
118
lua_strcase
(
"gettabup"
)
return
OP_GETTABUP
;
119
lua_strcase
(
"gettable"
)
return
OP_GETTABLE
;
120
lua_strcase
(
"geti"
)
return
OP_GETI
;
121
lua_strcase
(
"getfield"
)
return
OP_GETFIELD
;
122
123
lua_strcase
(
"settabup"
)
return
OP_SETTABUP
;
124
lua_strcase
(
"settable"
)
return
OP_SETTABLE
;
125
lua_strcase
(
"seti"
)
return
OP_SETI
;
126
lua_strcase
(
"setfield"
)
return
OP_SETFIELD
;
127
128
lua_strcase
(
"newtable"
)
return
OP_NEWTABLE
;
129
130
lua_strcase
(
"self"
)
return
OP_SELF
;
131
132
lua_strcase
(
"addi"
)
return
OP_ADDI
;
133
134
lua_strcase
(
"addk"
)
return
OP_ADDK
;
135
lua_strcase
(
"subk"
)
return
OP_SUBK
;
136
lua_strcase
(
"mulk"
)
return
OP_MULK
;
137
lua_strcase
(
"modk"
)
return
OP_MODK
;
138
lua_strcase
(
"powk"
)
return
OP_POWK
;
139
lua_strcase
(
"divk"
)
return
OP_DIVK
;
140
lua_strcase
(
"idivk"
)
return
OP_IDIVK
;
141
142
lua_strcase
(
"bandk"
)
return
OP_BANDK
;
143
lua_strcase
(
"bork"
)
return
OP_BORK
;
144
lua_strcase
(
"bxork"
)
return
OP_BXORK
;
145
146
lua_strcase
(
"shri"
)
return
OP_SHRI
;
147
lua_strcase
(
"shli"
)
return
OP_SHLI
;
148
149
lua_strcase
(
"add"
)
return
OP_ADD
;
150
lua_strcase
(
"sub"
)
return
OP_SUB
;
151
lua_strcase
(
"mul"
)
return
OP_MUL
;
152
lua_strcase
(
"mod"
)
return
OP_MOD
;
153
lua_strcase
(
"pow"
)
return
OP_POW
;
154
lua_strcase
(
"div"
)
return
OP_DIV
;
155
lua_strcase
(
"idiv"
)
return
OP_IDIV
;
156
157
lua_strcase
(
"band"
)
return
OP_BAND
;
158
lua_strcase
(
"bor"
)
return
OP_BOR
;
159
lua_strcase
(
"bxor"
)
return
OP_BXOR
;
160
lua_strcase
(
"shl"
)
return
OP_SHL
;
161
lua_strcase
(
"shr"
)
return
OP_SHR
;
162
163
lua_strcase
(
"mmbin"
)
return
OP_MMBIN
;
164
lua_strcase
(
"mmbini"
)
return
OP_MMBINI
;
165
lua_strcase
(
"mmbink"
)
return
OP_MMBINK
;
166
167
lua_strcase
(
"unm"
)
return
OP_UNM
;
168
lua_strcase
(
"bnot"
)
return
OP_BNOT
;
169
lua_strcase
(
"not"
)
return
OP_NOT
;
170
lua_strcase
(
"len"
)
return
OP_LEN
;
171
lua_strcase
(
"concat"
)
return
OP_CONCAT
;
172
173
lua_strcase
(
"close"
)
return
OP_CLOSE
;
174
lua_strcase
(
"tbc"
)
return
OP_TBC
;
175
lua_strcase
(
"jmp"
)
return
OP_JMP
;
176
lua_strcase
(
"eq"
)
return
OP_EQ
;
177
lua_strcase
(
"lt"
)
return
OP_LT
;
178
lua_strcase
(
"le"
)
return
OP_LE
;
179
180
lua_strcase
(
"eqk"
)
return
OP_EQK
;
181
lua_strcase
(
"eqi"
)
return
OP_EQI
;
182
lua_strcase
(
"lti"
)
return
OP_LTI
;
183
lua_strcase
(
"lei"
)
return
OP_LEI
;
184
lua_strcase
(
"gti"
)
return
OP_GTI
;
185
lua_strcase
(
"gei"
)
return
OP_GEI
;
186
187
lua_strcase
(
"test"
)
return
OP_TEST
;
188
lua_strcase
(
"testset"
)
return
OP_TESTSET
;
189
190
lua_strcase
(
"call"
)
return
OP_CALL
;
191
lua_strcase
(
"tailcall"
)
return
OP_TAILCALL
;
192
193
lua_strcase
(
"return"
)
return
OP_RETURN
;
194
lua_strcase
(
"return0"
)
return
OP_RETURN0
;
195
lua_strcase
(
"return1"
)
return
OP_RETURN1
;
196
197
lua_strcase
(
"forloop"
)
return
OP_FORLOOP
;
198
lua_strcase
(
"forprep"
)
return
OP_FORPREP
;
199
200
lua_strcase
(
"tforprep"
)
return
OP_TFORPREP
;
201
lua_strcase
(
"tforcall"
)
return
OP_TFORCALL
;
202
lua_strcase
(
"tforloop"
)
return
OP_TFORLOOP
;
203
204
lua_strcase
(
"setlist"
)
return
OP_SETLIST
;
205
206
lua_strcase
(
"closure"
)
return
OP_CLOSURE
;
207
208
lua_strcase
(
"vararg"
)
return
OP_VARARG
;
209
210
lua_strcase
(
"varargprep"
)
return
OP_VARARGPREP
;
211
212
lua_strcase
(
"extraarg"
)
return
OP_EXTRAARG
;
213
214
return
OP_EXTRAARG
+ 1;
// invalid
215
}
OP_DIV
@ OP_DIV
Definition:
8051_ops.h:51
OP_ADD
@ OP_ADD
Definition:
8051_ops.h:42
OP_MUL
@ OP_MUL
Definition:
8051_ops.h:63
OP_JMP
@ OP_JMP
Definition:
8051_ops.h:57
OP_SETLIST
@ OP_SETLIST
Definition:
arch_53.h:122
OP_EQ
@ OP_EQ
Definition:
arch_53.h:104
OP_VARARG
@ OP_VARARG
Definition:
arch_53.h:126
OP_CONCAT
@ OP_CONCAT
Definition:
arch_53.h:101
OP_BOR
@ OP_BOR
Definition:
arch_53.h:92
OP_SETTABLE
@ OP_SETTABLE
Definition:
arch_53.h:78
OP_POW
@ OP_POW
Definition:
arch_53.h:88
OP_NOT
@ OP_NOT
Definition:
arch_53.h:98
OP_TESTSET
@ OP_TESTSET
Definition:
arch_53.h:109
OP_MOD
@ OP_MOD
Definition:
arch_53.h:87
OP_CLOSURE
@ OP_CLOSURE
Definition:
arch_53.h:124
OP_SETUPVAL
@ OP_SETUPVAL
Definition:
arch_53.h:77
OP_FORPREP
@ OP_FORPREP
Definition:
arch_53.h:117
OP_LEN
@ OP_LEN
Definition:
arch_53.h:99
OP_LOADNIL
@ OP_LOADNIL
Definition:
arch_53.h:70
OP_BAND
@ OP_BAND
Definition:
arch_53.h:91
OP_SELF
@ OP_SELF
Definition:
arch_53.h:82
OP_SUB
@ OP_SUB
Definition:
arch_53.h:85
OP_SHR
@ OP_SHR
Definition:
arch_53.h:95
OP_LT
@ OP_LT
Definition:
arch_53.h:105
OP_TFORLOOP
@ OP_TFORLOOP
Definition:
arch_53.h:120
OP_SHL
@ OP_SHL
Definition:
arch_53.h:94
OP_TEST
@ OP_TEST
Definition:
arch_53.h:108
OP_TFORCALL
@ OP_TFORCALL
Definition:
arch_53.h:119
OP_FORLOOP
@ OP_FORLOOP
Definition:
arch_53.h:115
OP_GETTABLE
@ OP_GETTABLE
Definition:
arch_53.h:74
OP_LOADK
@ OP_LOADK
Definition:
arch_53.h:67
OP_GETUPVAL
@ OP_GETUPVAL
Definition:
arch_53.h:71
OP_SETTABUP
@ OP_SETTABUP
Definition:
arch_53.h:76
OP_IDIV
@ OP_IDIV
Definition:
arch_53.h:90
OP_GETTABUP
@ OP_GETTABUP
Definition:
arch_53.h:73
OP_LE
@ OP_LE
Definition:
arch_53.h:106
OP_RETURN
@ OP_RETURN
Definition:
arch_53.h:113
OP_BNOT
@ OP_BNOT
Definition:
arch_53.h:97
OP_MOVE
@ OP_MOVE
Definition:
arch_53.h:66
OP_UNM
@ OP_UNM
Definition:
arch_53.h:96
OP_EXTRAARG
@ OP_EXTRAARG
Definition:
arch_53.h:128
OP_LOADKX
@ OP_LOADKX
Definition:
arch_53.h:68
OP_NEWTABLE
@ OP_NEWTABLE
Definition:
arch_53.h:80
OP_BXOR
@ OP_BXOR
Definition:
arch_53.h:93
OP_TAILCALL
@ OP_TAILCALL
Definition:
arch_53.h:112
LUA_NUM_OPCODES
#define LUA_NUM_OPCODES
Definition:
arch_53.h:131
arch_54.h
OP_MMBINK
@ OP_MMBINK
Definition:
arch_54.h:131
OP_EQI
@ OP_EQI
Definition:
arch_54.h:148
OP_VARARGPREP
@ OP_VARARGPREP
Definition:
arch_54.h:178
OP_LFALSESKIP
@ OP_LFALSESKIP
Definition:
arch_54.h:78
OP_MMBINI
@ OP_MMBINI
Definition:
arch_54.h:130
OP_POWK
@ OP_POWK
Definition:
arch_54.h:104
OP_BANDK
@ OP_BANDK
Definition:
arch_54.h:108
OP_MMBIN
@ OP_MMBIN
Definition:
arch_54.h:129
OP_MULK
@ OP_MULK
Definition:
arch_54.h:102
OP_SETFIELD
@ OP_SETFIELD
Definition:
arch_54.h:92
OP_TBC
@ OP_TBC
Definition:
arch_54.h:141
OP_GTI
@ OP_GTI
Definition:
arch_54.h:151
OP_SETI
@ OP_SETI
Definition:
arch_54.h:91
OP_BORK
@ OP_BORK
Definition:
arch_54.h:109
OP_LOADI
@ OP_LOADI
Definition:
arch_54.h:73
OP_LTI
@ OP_LTI
Definition:
arch_54.h:149
OP_LOADF
@ OP_LOADF
Definition:
arch_54.h:74
OP_RETURN1
@ OP_RETURN1
Definition:
arch_54.h:162
OP_LOADFALSE
@ OP_LOADFALSE
Definition:
arch_54.h:77
OP_DIVK
@ OP_DIVK
Definition:
arch_54.h:105
OP_SHRI
@ OP_SHRI
Definition:
arch_54.h:112
OP_GETI
@ OP_GETI
Definition:
arch_54.h:86
OP_IDIVK
@ OP_IDIVK
Definition:
arch_54.h:106
OP_CLOSE
@ OP_CLOSE
Definition:
arch_54.h:140
OP_ADDK
@ OP_ADDK
Definition:
arch_54.h:100
OP_TFORPREP
@ OP_TFORPREP
Definition:
arch_54.h:168
OP_SHLI
@ OP_SHLI
Definition:
arch_54.h:113
OP_GETFIELD
@ OP_GETFIELD
Definition:
arch_54.h:87
OP_LOADTRUE
@ OP_LOADTRUE
Definition:
arch_54.h:79
OP_EQK
@ OP_EQK
Definition:
arch_54.h:147
OP_MODK
@ OP_MODK
Definition:
arch_54.h:103
OP_GEI
@ OP_GEI
Definition:
arch_54.h:152
OP_RETURN0
@ OP_RETURN0
Definition:
arch_54.h:161
OP_LEI
@ OP_LEI
Definition:
arch_54.h:150
OP_BXORK
@ OP_BXORK
Definition:
arch_54.h:110
OP_SUBK
@ OP_SUBK
Definition:
arch_54.h:101
NULL
#define NULL
Definition:
cris-opc.c:27
ut8
uint8_t ut8
Definition:
lh5801.h:11
list
static void list(RzEgg *egg)
Definition:
rz-gg.c:52
LuaOpNameList
char ** LuaOpNameList
Definition:
lua_arch.h:30
limit
static uint32_t const uint8_t uint32_t uint32_t limit
Definition:
memcmplen.h:45
OP_CALL
#define OP_CALL
Definition:
nios2.h:263
OP_ADDI
#define OP_ADDI
Definition:
nios2.h:253
get_lua54_opcode_by_name
ut8 get_lua54_opcode_by_name(const char *name, int limit)
Definition:
opcode_54.c:105
get_lua54_opnames
LuaOpNameList get_lua54_opnames(void)
Definition:
opcode_54.c:9
lua_strcase
#define lua_strcase(case_str)
Definition:
opcode_54.c:5
RZ_LOG_ERROR
#define RZ_LOG_ERROR(fmtstr,...)
Definition:
rz_log.h:58
RZ_NEWS
#define RZ_NEWS(x, y)
Definition:
rz_types.h:283
name
Definition:
z80asm.h:102
librz
asm
arch
luac
v54
opcode_54.c
Generated by
1.9.1