-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisline.h
107 lines (80 loc) · 3.21 KB
/
disline.h
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
105
106
107
// disline.h
#ifndef _DISLINE_H_
#define _DISLINE_H_
#include "disx.h"
#include "disstore.h"
// combination of addr and a sub-line to reference a dissassembly line
struct addrline_t
{
addr_t addr; // address of this instruction
uint8_t line; // line number within this address, starting at zero
// constructors
addrline_t() : addr(0), line(0) { }
addrline_t(addr_t _addr, uint8_t _line = 0) : addr(_addr), line(_line) { }
// compare two addrline_t for equality
inline bool operator==(const addrline_t &a)
{ return addr == a.addr && line == a.line; }
inline bool operator!=(const addrline_t &a)
{ return addr != a.addr || line != a.line; }
void next_addr(); // advance to next addr
void prev_addr(); // advance to prev addr
void next_line(); // advance to next line
void prev_line(); // advance to prev line
// get number of display lines at this address
int num_lines() const;
// return data length of this line
int get_len() const;
// set to first instruction at <= addr
void line_start(addr_t a);
};
class DisLine
{
public:
enum {
// tab columns in tabs[]
T_ADDR = 0, // listing address
T_HEX = 1, // object hex
T_LABEL = 2, // label
T_OPCODE = 3, // opcode
T_PARMS = 4, // parameters
T_CMT = 5, // comments
T_NTABS = 6,
T_SCRN = 7, // flag if in screen mode
// bits in line_cols
B_ADDR = 1 << T_ADDR,
B_HEX = 1 << T_HEX,
B_LABEL = 1 << T_LABEL,
B_OPCODE = 1 << T_OPCODE,
B_PARMS = 1 << T_PARMS,
B_SCRN = 1 << T_SCRN,
// column sets for various display modes
SCRN_COLS = B_ADDR | B_HEX | B_LABEL | B_OPCODE | B_PARMS | B_SCRN,
LIST_COLS = B_ADDR | B_HEX | B_LABEL | B_OPCODE | B_PARMS,
ASM_COLS = B_LABEL | B_OPCODE | B_PARMS,
// build_line flags
BL_NOLABEL = 1 << 0, // do not show label
BL_NOCOMMENT = 1 << 1, // do not show comment
};
static int tabs[T_NTABS-1]; // values of tab positions
static int line_cols; // false to show hex bytes, true for asm source format
static bool hard_tabs; // true to put hard tabs in listing
public:
void get_text(const addrline_t addr, char *s) const;
// used to initialize disscrn parameters
void get_start_addr(addrline_t &a) { a.addr = rom._base; a.line = 0; }
void get_end_addr (addrline_t &a) { a.addr = rom.get_end(); a.line = 0; }
// get the length of the instr at addr
// make addr become code
int make_code(addr_t addr, int &lfref, addr_t &refaddr);
void build_line(addr_t addr, char *s, const char *opcode,
const char* parms, int ofs = 0, int flags = 0) const;
int get_dis_line(addr_t addr, char *s, int &lfref, addr_t &refaddr) const;
void dis_org(char *s) const;
// create a text file with in asm or lst format
void write_listing(const char *ext, bool do_asm = false);
void write_asm(const char *ext) { write_listing(ext, true); }
private:
char *add_tab(char *s, int column, bool forceblank = true) const;
};
extern DisLine disline;
#endif // _DISLINE_H_