Rizin
unix-like reverse engineering framework and cli tools
opcode_53.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-3.0-only
2 // SPDX-FileCopyrightText: 2017 pancake <pancake@nopcode.org>
3 // SPDX-FileCopyrightText: 2021 Heersin <teablearcher@gmail.com>
4 
5 #include "arch_53.h"
6 #define lua_strcase(case_str) if ( \
7  ((limit) <= sizeof(case_str) - 1) && \
8  rz_str_ncasecmp((name), (case_str), sizeof(case_str) - 1) == 0)
9 
12  if (list == NULL) {
13  RZ_LOG_ERROR("Cannot allocate lua53 opcode list.\n");
14  return NULL;
15  }
16 
17  // Do not free the const string
18  list[OP_MOVE] = "move";
19  list[OP_LOADK] = "loadk";
20  list[OP_LOADKX] = "loadkx";
21  list[OP_LOADBOOL] = "loadbool";
22  list[OP_LOADNIL] = "loadnil";
23  list[OP_GETUPVAL] = "getupval";
24  list[OP_GETTABUP] = "gettabup";
25  list[OP_GETTABLE] = "gettable";
26  list[OP_SETTABUP] = "settabup";
27  list[OP_SETUPVAL] = "setupval";
28  list[OP_SETTABLE] = "settable";
29  list[OP_NEWTABLE] = "newtable";
30  list[OP_SELF] = "self";
31  list[OP_ADD] = "add";
32  list[OP_SUB] = "sub";
33  list[OP_MUL] = "mul";
34  list[OP_MOD] = "mod";
35  list[OP_POW] = "pow";
36  list[OP_DIV] = "div";
37  list[OP_IDIV] = "idiv";
38  list[OP_BAND] = "band";
39  list[OP_BOR] = "bor";
40  list[OP_BXOR] = "bxor";
41  list[OP_SHL] = "shl";
42  list[OP_SHR] = "shr";
43  list[OP_UNM] = "unm";
44  list[OP_BNOT] = "bnot";
45  list[OP_NOT] = "not";
46  list[OP_LEN] = "len";
47  list[OP_CONCAT] = "concat";
48  list[OP_JMP] = "jmp";
49  list[OP_EQ] = "eq";
50  list[OP_LT] = "lt";
51  list[OP_LE] = "le";
52  list[OP_TEST] = "test";
53  list[OP_TESTSET] = "testset";
54  list[OP_CALL] = "call";
55  list[OP_TAILCALL] = "tailcall";
56  list[OP_RETURN] = "return";
57  list[OP_FORLOOP] = "forloop";
58  list[OP_FORPREP] = "forprep";
59  list[OP_TFORCALL] = "tforcall";
60  list[OP_TFORLOOP] = "tforloop";
61  list[OP_SETLIST] = "setlist";
62  list[OP_CLOSURE] = "closure";
63  list[OP_VARARG] = "vararg";
64  list[OP_EXTRAARG] = "extraarg";
65 
66  return list;
67 }
68 
70  lua_strcase("move") return OP_MOVE;
71  lua_strcase("loadk") return OP_LOADK;
72  lua_strcase("loadkx") return OP_LOADKX;
73  lua_strcase("loadbool") return OP_LOADBOOL;
74  lua_strcase("loadnil") return OP_LOADNIL;
75  lua_strcase("getupval") return OP_GETUPVAL;
76  lua_strcase("gettabup") return OP_GETTABUP;
77  lua_strcase("gettable") return OP_GETTABLE;
78  lua_strcase("settabup") return OP_SETTABUP;
79  lua_strcase("setupval") return OP_SETUPVAL;
80  lua_strcase("settable") return OP_SETTABLE;
81  lua_strcase("newtable") return OP_NEWTABLE;
82 
83  lua_strcase("self") return OP_SELF;
84  lua_strcase("add") return OP_ADD;
85  lua_strcase("sub") return OP_SUB;
86  lua_strcase("mul") return OP_MUL;
87  lua_strcase("mod") return OP_MOD;
88  lua_strcase("pow") return OP_POW;
89  lua_strcase("div") return OP_DIV;
90  lua_strcase("idiv") return OP_IDIV;
91  lua_strcase("band") return OP_BAND;
92  lua_strcase("bor") return OP_BOR;
93  lua_strcase("bxor") return OP_BXOR;
94  lua_strcase("shl") return OP_SHL;
95  lua_strcase("shr") return OP_SHR;
96  lua_strcase("unm") return OP_UNM;
97  lua_strcase("bnot") return OP_BNOT;
98  lua_strcase("not") return OP_NOT;
99 
100  lua_strcase("len") return OP_LEN;
101  lua_strcase("concat") return OP_CONCAT;
102  lua_strcase("jmp") return OP_JMP;
103  lua_strcase("eq") return OP_EQ;
104  lua_strcase("lt") return OP_LT;
105  lua_strcase("le") return OP_LE;
106  lua_strcase("test") return OP_TEST;
107  lua_strcase("testset") return OP_TESTSET;
108 
109  lua_strcase("call") return OP_CALL;
110  lua_strcase("tailcall") return OP_TAILCALL;
111  lua_strcase("return") return OP_RETURN;
112  lua_strcase("forloop") return OP_FORLOOP;
113  lua_strcase("forprep") return OP_FORPREP;
114  lua_strcase("tforcall") return OP_TFORCALL;
115  lua_strcase("tforloop") return OP_TFORLOOP;
116  lua_strcase("setlist") return OP_SETLIST;
117  lua_strcase("closure") return OP_CLOSURE;
118  lua_strcase("vararg") return OP_VARARG;
119  lua_strcase("extraarg") return OP_EXTRAARG;
120 
121  return OP_EXTRAARG + 1; // invalid
122 }
@ OP_DIV
Definition: 8051_ops.h:51
@ OP_ADD
Definition: 8051_ops.h:42
@ OP_MUL
Definition: 8051_ops.h:63
@ OP_JMP
Definition: 8051_ops.h:57
@ OP_SETLIST
Definition: arch_53.h:122
@ OP_EQ
Definition: arch_53.h:104
@ OP_VARARG
Definition: arch_53.h:126
@ OP_CONCAT
Definition: arch_53.h:101
@ OP_BOR
Definition: arch_53.h:92
@ OP_SETTABLE
Definition: arch_53.h:78
@ OP_POW
Definition: arch_53.h:88
@ OP_NOT
Definition: arch_53.h:98
@ OP_TESTSET
Definition: arch_53.h:109
@ OP_MOD
Definition: arch_53.h:87
@ OP_CLOSURE
Definition: arch_53.h:124
@ OP_SETUPVAL
Definition: arch_53.h:77
@ OP_FORPREP
Definition: arch_53.h:117
@ OP_LEN
Definition: arch_53.h:99
@ OP_LOADNIL
Definition: arch_53.h:70
@ OP_BAND
Definition: arch_53.h:91
@ OP_SELF
Definition: arch_53.h:82
@ OP_SUB
Definition: arch_53.h:85
@ OP_SHR
Definition: arch_53.h:95
@ OP_LT
Definition: arch_53.h:105
@ OP_TFORLOOP
Definition: arch_53.h:120
@ OP_SHL
Definition: arch_53.h:94
@ OP_TEST
Definition: arch_53.h:108
@ OP_TFORCALL
Definition: arch_53.h:119
@ OP_FORLOOP
Definition: arch_53.h:115
@ OP_GETTABLE
Definition: arch_53.h:74
@ OP_LOADK
Definition: arch_53.h:67
@ OP_GETUPVAL
Definition: arch_53.h:71
@ OP_SETTABUP
Definition: arch_53.h:76
@ OP_IDIV
Definition: arch_53.h:90
@ OP_GETTABUP
Definition: arch_53.h:73
@ OP_LE
Definition: arch_53.h:106
@ OP_RETURN
Definition: arch_53.h:113
@ OP_BNOT
Definition: arch_53.h:97
@ OP_MOVE
Definition: arch_53.h:66
@ OP_UNM
Definition: arch_53.h:96
@ OP_EXTRAARG
Definition: arch_53.h:128
@ OP_LOADKX
Definition: arch_53.h:68
@ OP_NEWTABLE
Definition: arch_53.h:80
@ OP_LOADBOOL
Definition: arch_53.h:69
@ OP_BXOR
Definition: arch_53.h:93
@ OP_TAILCALL
Definition: arch_53.h:112
#define LUA_NUM_OPCODES
Definition: arch_53.h:131
#define NULL
Definition: cris-opc.c:27
uint8_t ut8
Definition: lh5801.h:11
static void list(RzEgg *egg)
Definition: rz-gg.c:52
char ** LuaOpNameList
Definition: lua_arch.h:30
static uint32_t const uint8_t uint32_t uint32_t limit
Definition: memcmplen.h:45
#define OP_CALL
Definition: nios2.h:263
ut8 get_lua53_opcode_by_name(const char *name, int limit)
Definition: opcode_53.c:69
LuaOpNameList get_lua53_opnames(void)
Definition: opcode_53.c:10
#define lua_strcase(case_str)
Definition: opcode_53.c:6
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
#define RZ_NEWS(x, y)
Definition: rz_types.h:283
Definition: z80asm.h:102