Rizin
unix-like reverse engineering framework and cli tools
ebc_disas.h File Reference
#include <stdint.h>

Go to the source code of this file.

Classes

struct  ebc_command
 

Macros

#define EBC_OPCODE_MASK   0x3F
 
#define EBC_MODIFIER_MASK   0xC0
 
#define EBC_OPERAND1_MASK   0x07
 
#define EBC_OPERAND2_MASK   (0x07 << 4)
 
#define EBC_OPERAND1_DIRECT   0x08
 
#define EBC_OPERAND2_DIRECT   0xA0
 
#define EBC_OPERAND1_INDX   0x01
 
#define EBC_OPERAND2_INDX   0x02
 
#define EBC_GET_OPCODE(byte)   (byte & EBC_OPCODE_MASK)
 
#define EBC_INSTR_MAXLEN   32
 
#define EBC_OPERANDS_MAXLEN   32
 
#define EBC_NTH_BIT(n)   (1ULL << n)
 
#define EBC_N_BIT_MASK(n)   (~(~0U << (n)))
 
#define EBC_GET_BIT(v, n)   ((v >> n) & 1)
 
#define TEST_BIT(x, n)   (x & (1 << n))
 

Typedefs

typedef struct ebc_command ebc_command_t
 

Enumerations

enum  ebc_opcodes {
  EBC_BREAK = 0x00 , EBC_JMP = 0x01 , EBC_JMP8 = 0x02 , EBC_CALL = 0x03 ,
  EBC_RET = 0x04 , EBC_CMPEQ = 0x05 , EBC_CMPLTE = 0x06 , EBC_CMPGTE = 0x07 ,
  EBC_CMPULTE = 0x08 , EBC_CMPUGTE = 0x09 , EBC_NOT = 0x0A , EBC_NEG = 0x0B ,
  EBC_ADD = 0x0C , EBC_SUB = 0x0D , EBC_MUL = 0x0E , EBC_MULU = 0x0F ,
  EBC_DIV = 0x10 , EBC_DIVU = 0x11 , EBC_MOD = 0x12 , EBC_MODU = 0x13 ,
  EBC_AND = 0x14 , EBC_OR = 0x15 , EBC_XOR = 0x16 , EBC_SHL = 0x17 ,
  EBC_SHR = 0x18 , EBC_ASHR = 0x19 , EBC_EXTNDB = 0x1A , EBC_EXTNDW = 0x1B ,
  EBC_EXTNDD = 0x1C , EBC_MOVBW = 0x1D , EBC_MOVWW = 0x1E , EBC_MOVDW = 0x1F ,
  EBC_MOVQW = 0x20 , EBC_MOVBD = 0x21 , EBC_MOVWD = 0x22 , EBC_MOVDD = 0x23 ,
  EBC_MOVQD = 0x24 , EBC_MOVSNW = 0x25 , EBC_MOVSND = 0x26 , EBC_UNDEFINED = 0x27 ,
  EBC_MOVQQ = 0x28 , EBC_LOADSP = 0x29 , EBC_STORESP = 0x2A , EBC_PUSH = 0x2B ,
  EBC_POP = 0x2C , EBC_CMPIEQ = 0x2D , EBC_CMPILTE = 0x2E , EBC_CMPIGTE = 0x2F ,
  EBC_CMPIULTE = 0x30 , EBC_CMPIUGTE = 0x31 , EBC_MOVNW = 0x32 , EBC_MOVND = 0x33 ,
  EBC_UNDEFINED2 = 0x34 , EBC_PUSHN = 0x35 , EBC_POPN = 0x36 , EBC_MOVI = 0x37 ,
  EBC_MOVIN = 0x38 , EBC_MOVREL = 0x39 , EBC_COMMAND_NUM
}
 

Functions

int ebc_decode_command (const uint8_t *instr, ebc_command_t *cmd)
 

Macro Definition Documentation

◆ EBC_GET_BIT

#define EBC_GET_BIT (   v,
  n 
)    ((v >> n) & 1)

Definition at line 25 of file ebc_disas.h.

◆ EBC_GET_OPCODE

#define EBC_GET_OPCODE (   byte)    (byte & EBC_OPCODE_MASK)

Definition at line 18 of file ebc_disas.h.

◆ EBC_INSTR_MAXLEN

#define EBC_INSTR_MAXLEN   32

Definition at line 20 of file ebc_disas.h.

◆ EBC_MODIFIER_MASK

#define EBC_MODIFIER_MASK   0xC0

Definition at line 10 of file ebc_disas.h.

◆ EBC_N_BIT_MASK

#define EBC_N_BIT_MASK (   n)    (~(~0U << (n)))

Definition at line 24 of file ebc_disas.h.

◆ EBC_NTH_BIT

#define EBC_NTH_BIT (   n)    (1ULL << n)

Definition at line 23 of file ebc_disas.h.

◆ EBC_OPCODE_MASK

#define EBC_OPCODE_MASK   0x3F

Definition at line 9 of file ebc_disas.h.

◆ EBC_OPERAND1_DIRECT

#define EBC_OPERAND1_DIRECT   0x08

Definition at line 13 of file ebc_disas.h.

◆ EBC_OPERAND1_INDX

#define EBC_OPERAND1_INDX   0x01

Definition at line 15 of file ebc_disas.h.

◆ EBC_OPERAND1_MASK

#define EBC_OPERAND1_MASK   0x07

Definition at line 11 of file ebc_disas.h.

◆ EBC_OPERAND2_DIRECT

#define EBC_OPERAND2_DIRECT   0xA0

Definition at line 14 of file ebc_disas.h.

◆ EBC_OPERAND2_INDX

#define EBC_OPERAND2_INDX   0x02

Definition at line 16 of file ebc_disas.h.

◆ EBC_OPERAND2_MASK

#define EBC_OPERAND2_MASK   (0x07 << 4)

Definition at line 12 of file ebc_disas.h.

◆ EBC_OPERANDS_MAXLEN

#define EBC_OPERANDS_MAXLEN   32

Definition at line 21 of file ebc_disas.h.

◆ TEST_BIT

#define TEST_BIT (   x,
  n 
)    (x & (1 << n))

Definition at line 27 of file ebc_disas.h.

Typedef Documentation

◆ ebc_command_t

typedef struct ebc_command ebc_command_t

Enumeration Type Documentation

◆ ebc_opcodes

Enumerator
EBC_BREAK 
EBC_JMP 
EBC_JMP8 
EBC_CALL 
EBC_RET 
EBC_CMPEQ 
EBC_CMPLTE 
EBC_CMPGTE 
EBC_CMPULTE 
EBC_CMPUGTE 
EBC_NOT 
EBC_NEG 
EBC_ADD 
EBC_SUB 
EBC_MUL 
EBC_MULU 
EBC_DIV 
EBC_DIVU 
EBC_MOD 
EBC_MODU 
EBC_AND 
EBC_OR 
EBC_XOR 
EBC_SHL 
EBC_SHR 
EBC_ASHR 
EBC_EXTNDB 
EBC_EXTNDW 
EBC_EXTNDD 
EBC_MOVBW 
EBC_MOVWW 
EBC_MOVDW 
EBC_MOVQW 
EBC_MOVBD 
EBC_MOVWD 
EBC_MOVDD 
EBC_MOVQD 
EBC_MOVSNW 
EBC_MOVSND 
EBC_UNDEFINED 
EBC_MOVQQ 
EBC_LOADSP 
EBC_STORESP 
EBC_PUSH 
EBC_POP 
EBC_CMPIEQ 
EBC_CMPILTE 
EBC_CMPIGTE 
EBC_CMPIULTE 
EBC_CMPIUGTE 
EBC_MOVNW 
EBC_MOVND 
EBC_UNDEFINED2 
EBC_PUSHN 
EBC_POPN 
EBC_MOVI 
EBC_MOVIN 
EBC_MOVREL 
EBC_COMMAND_NUM 

Definition at line 29 of file ebc_disas.h.

29  {
30  EBC_BREAK = 0x00,
31  EBC_JMP = 0x01,
32  EBC_JMP8 = 0x02,
33  EBC_CALL = 0x03,
34  EBC_RET = 0x04,
35  EBC_CMPEQ = 0x05,
36  EBC_CMPLTE = 0x06,
37  EBC_CMPGTE = 0x07,
38  EBC_CMPULTE = 0x08,
39  EBC_CMPUGTE = 0x09,
40  EBC_NOT = 0x0A,
41  EBC_NEG = 0x0B,
42  EBC_ADD = 0x0C,
43  EBC_SUB = 0x0D,
44  EBC_MUL = 0x0E,
45  EBC_MULU = 0x0F,
46  EBC_DIV = 0x10,
47  EBC_DIVU = 0x11,
48  EBC_MOD = 0x12,
49  EBC_MODU = 0x13,
50  EBC_AND = 0x14,
51  EBC_OR = 0x15,
52  EBC_XOR = 0x16,
53  EBC_SHL = 0x17,
54  EBC_SHR = 0x18,
55  EBC_ASHR = 0x19,
56  EBC_EXTNDB = 0x1A,
57  EBC_EXTNDW = 0x1B,
58  EBC_EXTNDD = 0x1C,
59  EBC_MOVBW = 0x1D,
60  EBC_MOVWW = 0x1E,
61  EBC_MOVDW = 0x1F,
62  EBC_MOVQW = 0x20,
63  EBC_MOVBD = 0x21,
64  EBC_MOVWD = 0x22,
65  EBC_MOVDD = 0x23,
66  EBC_MOVQD = 0x24,
67  EBC_MOVSNW = 0x25,
68  EBC_MOVSND = 0x26,
69  EBC_UNDEFINED = 0x27,
70  EBC_MOVQQ = 0x28,
71  EBC_LOADSP = 0x29,
72  EBC_STORESP = 0x2A,
73  EBC_PUSH = 0x2B,
74  EBC_POP = 0x2C,
75  EBC_CMPIEQ = 0x2D,
76  EBC_CMPILTE = 0x2E,
77  EBC_CMPIGTE = 0x2F,
78  EBC_CMPIULTE = 0x30,
79  EBC_CMPIUGTE = 0x31,
80  EBC_MOVNW = 0x32,
81  EBC_MOVND = 0x33,
82  EBC_UNDEFINED2 = 0x34,
83  EBC_PUSHN = 0x35,
84  EBC_POPN = 0x36,
85  EBC_MOVI = 0x37,
86  EBC_MOVIN = 0x38,
87  EBC_MOVREL = 0x39,
89 };
@ EBC_LOADSP
Definition: ebc_disas.h:71
@ EBC_NOT
Definition: ebc_disas.h:40
@ EBC_ADD
Definition: ebc_disas.h:42
@ EBC_PUSH
Definition: ebc_disas.h:73
@ EBC_SHL
Definition: ebc_disas.h:53
@ EBC_CMPIUGTE
Definition: ebc_disas.h:79
@ EBC_JMP8
Definition: ebc_disas.h:32
@ EBC_MOVDD
Definition: ebc_disas.h:65
@ EBC_MUL
Definition: ebc_disas.h:44
@ EBC_MULU
Definition: ebc_disas.h:45
@ EBC_DIV
Definition: ebc_disas.h:46
@ EBC_ASHR
Definition: ebc_disas.h:55
@ EBC_SUB
Definition: ebc_disas.h:43
@ EBC_CMPULTE
Definition: ebc_disas.h:38
@ EBC_POP
Definition: ebc_disas.h:74
@ EBC_EXTNDD
Definition: ebc_disas.h:58
@ EBC_MOVDW
Definition: ebc_disas.h:61
@ EBC_COMMAND_NUM
Definition: ebc_disas.h:88
@ EBC_UNDEFINED
Definition: ebc_disas.h:69
@ EBC_CMPLTE
Definition: ebc_disas.h:36
@ EBC_MOD
Definition: ebc_disas.h:48
@ EBC_STORESP
Definition: ebc_disas.h:72
@ EBC_RET
Definition: ebc_disas.h:34
@ EBC_CALL
Definition: ebc_disas.h:33
@ EBC_MOVQQ
Definition: ebc_disas.h:70
@ EBC_MOVQW
Definition: ebc_disas.h:62
@ EBC_XOR
Definition: ebc_disas.h:52
@ EBC_EXTNDW
Definition: ebc_disas.h:57
@ EBC_MOVQD
Definition: ebc_disas.h:66
@ EBC_CMPEQ
Definition: ebc_disas.h:35
@ EBC_MOVI
Definition: ebc_disas.h:85
@ EBC_MODU
Definition: ebc_disas.h:49
@ EBC_CMPIULTE
Definition: ebc_disas.h:78
@ EBC_CMPGTE
Definition: ebc_disas.h:37
@ EBC_MOVSNW
Definition: ebc_disas.h:67
@ EBC_DIVU
Definition: ebc_disas.h:47
@ EBC_CMPUGTE
Definition: ebc_disas.h:39
@ EBC_JMP
Definition: ebc_disas.h:31
@ EBC_MOVREL
Definition: ebc_disas.h:87
@ EBC_MOVWW
Definition: ebc_disas.h:60
@ EBC_NEG
Definition: ebc_disas.h:41
@ EBC_CMPILTE
Definition: ebc_disas.h:76
@ EBC_EXTNDB
Definition: ebc_disas.h:56
@ EBC_MOVBW
Definition: ebc_disas.h:59
@ EBC_MOVIN
Definition: ebc_disas.h:86
@ EBC_SHR
Definition: ebc_disas.h:54
@ EBC_BREAK
Definition: ebc_disas.h:30
@ EBC_POPN
Definition: ebc_disas.h:84
@ EBC_MOVSND
Definition: ebc_disas.h:68
@ EBC_CMPIGTE
Definition: ebc_disas.h:77
@ EBC_AND
Definition: ebc_disas.h:50
@ EBC_MOVBD
Definition: ebc_disas.h:63
@ EBC_MOVWD
Definition: ebc_disas.h:64
@ EBC_UNDEFINED2
Definition: ebc_disas.h:82
@ EBC_PUSHN
Definition: ebc_disas.h:83
@ EBC_CMPIEQ
Definition: ebc_disas.h:75
@ EBC_OR
Definition: ebc_disas.h:51
@ EBC_MOVNW
Definition: ebc_disas.h:80
@ EBC_MOVND
Definition: ebc_disas.h:81

Function Documentation

◆ ebc_decode_command()

int ebc_decode_command ( const uint8_t instr,
ebc_command_t cmd 
)

Definition at line 986 of file ebc_disas.c.

986  {
987  if ((instr[0] & EBC_OPCODE_MASK) > 0x39) {
988  {
989  return -1;
990  }
991  }
992  return decodes[instr[0] & EBC_OPCODE_MASK](instr, cmd);
993 }
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags cmd
Definition: sflib.h:79
static decode decodes[EBC_COMMAND_NUM]
Definition: ebc_disas.c:925
#define EBC_OPCODE_MASK
Definition: ebc_disas.h:9

References cmd, decodes, and EBC_OPCODE_MASK.

Referenced by disassemble(), and ebc_op().