forked from rumpeltux/Stm8Ida
-
Notifications
You must be signed in to change notification settings - Fork 2
/
stm8.hpp
104 lines (90 loc) · 4.17 KB
/
stm8.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#ifndef _ST8_HPP
#define _ST8_HPP
#define NO_OBSOLETE_FUNCS
#pragma warning(disable:4005 4312 4244 4520 4018 4267 4800 4996 4482 4101 4002 4102 4101)
#include "../idaidp.hpp"
#include <diskio.hpp>
#include "ins.hpp"
// o_void Inherent nop
// o_imm Immediate ld A,#$55
// o_mem Direct ld A,$55
// o_displ Indexed ld A,($55,X)
// o_mem Indirect ld A,([$55],X)
// o_near Relative jrne loop
// o_mem Bit operation bset byte,#5
// type Mode Syntax Destination Ptradr PtrSz Len
// ------- --------------------------- ------------------------ ---------- ------ ---- ---
// o_void Inherent nop + 0
// o_imm Immediate ld A,#$55 + 1
// o_mem Short Direct ld A,$10 00..FF + 1
// o_mem Long Direct ld A,$1000 0000..FFFF + 2
// o_phras No Offset Direct Indexed ld A,(X) 00..FF + 0
// o_displ Short Direct Indexed ld A,($10,X) 00..1FE + 1
// o_displ Long Direct Indexed ld A,($1000,X) 0000..FFFF + 2
// o_mem Short Indirect ld A,[$10] 00..FF 00..FF byte + 2
// o_mem Long Indirect ld A,[$10.w] 0000..FFFF 00..FF word + 2
// o_mem Extended Indirect ld A,[$10.e]
// o_mem Short Indirect Indexed ld A,([$10],X) 00..1FE 00..FF byte + 2
// o_mem Long Indirect Indexed ld A,([$10.w],X) 0000..FFFF 00..FF word + 2
// o_mem Extended Indirect Indexed ld A,([$10.e],X)
// o_near Relative Direct jrne loop PC+/-127 + 1
// o_mem Relative Indirect jrne [$10] PC+/-127 00..FF byte + 2
// o_mem Bit Direct bset $10,#7 00..FF + 1
// o_mem Bit Indirect bset [$10],#7 00..FF 00..FF byte + 2
// o_mem Bit Direct Relative btjt $10,#7,skip 00..FF + 2
// o_mem Bit Indirect Relative btjt [$10],#7,skip 00..FF 00..FF byte + 3
#define aux_long 0x0001 // long addressing mode
#define aux_indir 0x0002 // o_mem: indirect addressing mode
#define aux_index 0x0004 // o_mem: indexed addressing mode
#define aux_16 0x0008 // 16bit displacement
#define aux_extd 0x0010 // extended addessing mode
//------------------------------------------------------------------
#ifdef _MSC_VER
#define ENUM8BIT : uint8
#else
#define ENUM8BIT
#endif
enum regnum_t ENUM8BIT
{
A, X, Y, CC, SP,
XL, XH, YL, YH,
ds, cs,
};
//------------------------------------------------------------------
enum
{
ASM_STASM,
ASM_COSMIC
};
struct opcode_t
{
uchar itype;
uchar opcode;
ushort dst;
ushort src;
uchar len;
bool extended;
uchar iform;
};
//------------------------------------------------------------------
extern netnode helper;
extern qstring device;
ea_t calc_mem(const insn_t &insn, ea_t ea); // map virtual to physical ea
const ioport_t *find_sym(ea_t address);
const struct opcode_t &get_opcode_info(uint8 opcode);
//------------------------------------------------------------------
void interr(const insn_t &insn, const char *module);
void idaapi stm8_header(outctx_t &ctx);
void idaapi stm8_footer(outctx_t &ctx);
void idaapi stm8_segstart(outctx_t &ctx, segment_t *Sarea);
void idaapi stm8_segend(outctx_t &ctx, segment_t *seg);
int idaapi stm8_is_align_insn(ea_t ea);
void idaapi stm8_gen_stkvar_def(outctx_t &ctx, const member_t *mptr, sval_t v);
int idaapi ana(insn_t *_insn);
int idaapi emu(const insn_t &insn);
bool idaapi stm8_is_switch(switch_info_t *si, const insn_t &insn);
int is_sane_insn(const insn_t &insn, int nocrefs);
int get_frame_retsize(func_t *);
int is_jump_func(const func_t *pfn, ea_t *jump_target);
int may_be_func(void); // can a function start here?
#endif // _ST8_HPP