Rizin
unix-like reverse engineering framework and cli tools
cs_mnemonics.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2016-2018 pancake <pancake@nopcode.org>
2 // SPDX-License-Identifier: LGPL-3.0-only
3 
4 static char *mnemonics(RzAsm *a, int id, bool json) {
5  int i;
6  a->cur->disassemble(a, NULL, NULL, -1);
7  if (id != -1) {
8  const char *name = cs_insn_name(cd, id);
9  if (json) {
10  return name ? rz_str_newf("[\"%s\"]\n", name) : NULL;
11  }
12  return name ? strdup(name) : NULL;
13  }
14  RzStrBuf *buf = rz_strbuf_new("");
15  if (json) {
16  rz_strbuf_append(buf, "[");
17  }
18  for (i = 1;; i++) {
19  const char *op = cs_insn_name(cd, i);
20  if (!op) {
21  break;
22  }
23  if (json) {
24  rz_strbuf_append(buf, "\"");
25  }
27  if (json) {
28  if (cs_insn_name(cd, i + 1)) {
29  rz_strbuf_append(buf, "\",");
30  } else {
31  rz_strbuf_append(buf, "\"]\n");
32  }
33  } else {
34  rz_strbuf_append(buf, "\n");
35  }
36  }
37  return rz_strbuf_drain(buf);
38 }
lzma_index ** i
Definition: index.h:629
static csh cd
Definition: asm_mips_cs.c:10
#define NULL
Definition: cris-opc.c:27
CAPSTONE_EXPORT const char *CAPSTONE_API cs_insn_name(csh ud, unsigned int insn)
Definition: cs.c:1166
static char * mnemonics(RzAsm *a, int id, bool json)
Definition: cs_mnemonics.c:4
voidpf void * buf
Definition: ioapi.h:138
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API RZ_OWN char * rz_strbuf_drain(RzStrBuf *sb)
Definition: strbuf.c:342
RZ_API bool rz_strbuf_append(RzStrBuf *sb, const char *s)
Definition: strbuf.c:222
RZ_API RzStrBuf * rz_strbuf_new(const char *s)
Definition: strbuf.c:8
#define a(i)
Definition: sha256.c:41
Definition: z80asm.h:102
Definition: dis.c:32