Rizin
unix-like reverse engineering framework and cli tools
dis.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2007 sorbo
2 // SPDX-FileCopyrightText: 2010-2019 pancake <pancake@nopcode.org>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #ifndef _INCLUDE_XAP_DIS_H_
6 #define _INCLUDE_XAP_DIS_H_
7 
8 #include <rz_types.h>
9 
10 #define __packed __attribute__((__packed__))
11 
12 struct instruction {
14  in_reg : 2,
15  in_opcode : 4,
17 #if __sun || defined(_MSC_VER)
18 #ifndef _MSC_VER
19 #warning XXX related to sunstudio :O
20 #endif
21 };
22 #else
24 #endif
25 
26 struct directive {
27  struct instruction d_inst;
28  int d_operand;
29  int d_prefix;
30  unsigned int d_off;
31  char d_asm[128];
32  struct directive *d_next;
33 };
34 
35 struct label {
36  char l_name[128];
37  unsigned int l_off;
38  struct directive *l_refs[666];
39  int l_refc;
40  struct label *l_next;
41 };
42 
43 struct state {
44  int s_prefix;
45  unsigned int s_prefix_val;
47  unsigned int s_off;
48  char *s_fname;
49  int s_u;
50  unsigned int s_labelno;
51  const unsigned char *s_buf;
52  struct directive s_dirs;
53  struct label s_labels;
55  int s_format;
56  int s_nop;
57  struct directive *s_nopd;
59 };
60 
61 #define MODE_MASK 3
62 #define REG_SHIFT 2
63 #define REG_MASK 3
64 #define OPCODE_SHIFT 4
65 #define OPCODE_MASK 0xF
66 #define OPERAND_SHIFT 8
67 
68 #define INST_NOP 0x0000
69 #define INST_BRK 0x0004
70 #define INST_SLEEP 0x0008
71 #define INST_U 0x0009
72 #define INST_SIF 0x000C
73 #define INST_RTS 0x00E2
74 #define INST_BRXL 0xfe09
75 #define INST_BC 0xff09
76 
77 #define REG_AH 0
78 #define REG_AL 1
79 #define REG_X 2
80 #define REG_Y 3
81 
82 #define DATA_MODE_IMMEDIATE 0
83 #define DATA_MODE_DIRECT 1
84 #define DATA_MODE_INDEXED_X 2
85 #define DATA_MODE_INDEXED_Y 3
86 
87 #define ADDR_MODE_RELATIVE 0
88 #define ADDR_MODE_X_RELATIVE 2
89 
90 static void xap_decode(struct state *s, struct directive *d);
91 
92 #endif
uint16_t ut16
#define __packed
Definition: dis.h:10
static void xap_decode(struct state *s, struct directive *d)
string FILE
Definition: benchmark.py:21
static RzSocket * s
Definition: rtr.c:28
#define d(i)
Definition: sha256.c:44
Definition: dis.h:26
unsigned int d_off
Definition: dis.h:30
int d_operand
Definition: dis.h:28
int d_prefix
Definition: dis.h:29
struct instruction d_inst
Definition: dis.h:27
struct directive * d_next
Definition: dis.h:32
char d_asm[128]
Definition: dis.h:31
ut16 in_mode
Definition: dis.h:13
ut16 in_opcode
Definition: dis.h:15
ut16 in_operand
Definition: dis.h:16
ut16 in_reg
Definition: dis.h:14
Definition: dis.h:35
int l_refc
Definition: dis.h:39
struct directive * l_refs[666]
Definition: dis.h:38
char l_name[128]
Definition: dis.h:36
unsigned int l_off
Definition: dis.h:37
struct label * l_next
Definition: dis.h:40
Definition: dis.h:43
int s_nop
Definition: dis.h:56
int s_prefix
Definition: dis.h:44
const unsigned char * s_buf
Definition: dis.h:51
unsigned int s_off
Definition: dis.h:47
unsigned int s_prefix_val
Definition: dis.h:45
FILE * s_in
Definition: dis.h:46
struct directive s_dirs
Definition: dis.h:52
unsigned int s_labelno
Definition: dis.h:50
struct directive * s_nopd
Definition: dis.h:57
char * s_fname
Definition: dis.h:48
int s_u
Definition: dis.h:49
int s_ff_quirk
Definition: dis.h:58
FILE * s_out
Definition: dis.h:54
struct label s_labels
Definition: dis.h:53
int s_format
Definition: dis.h:55