1 |
cebix |
1.1 |
/* |
2 |
cebix |
1.6 |
* mon.h - cxmon main program |
3 |
cebix |
1.1 |
* |
4 |
cebix |
1.12 |
* cxmon (C) Christian Bauer, Marc Hellwig |
5 |
cebix |
1.2 |
* |
6 |
|
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
|
* it under the terms of the GNU General Public License as published by |
8 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
9 |
|
|
* (at your option) any later version. |
10 |
|
|
* |
11 |
|
|
* This program is distributed in the hope that it will be useful, |
12 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
|
|
* GNU General Public License for more details. |
15 |
|
|
* |
16 |
|
|
* You should have received a copy of the GNU General Public License |
17 |
|
|
* along with this program; if not, write to the Free Software |
18 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 |
cebix |
1.1 |
*/ |
20 |
|
|
|
21 |
cebix |
1.2 |
#ifndef MON_H |
22 |
|
|
#define MON_H |
23 |
cebix |
1.1 |
|
24 |
cebix |
1.3 |
#include <stdio.h> |
25 |
|
|
|
26 |
cebix |
1.1 |
|
27 |
cebix |
1.2 |
/* |
28 |
|
|
* Initialization, deinitialization and invocation |
29 |
|
|
*/ |
30 |
cebix |
1.1 |
|
31 |
cebix |
1.10 |
void mon_init(); |
32 |
|
|
void mon_exit(); |
33 |
cebix |
1.12 |
void mon(int argc, const char **argv); |
34 |
cebix |
1.1 |
|
35 |
|
|
|
36 |
|
|
/* |
37 |
|
|
* Definitions for adding commands to mon |
38 |
|
|
*/ |
39 |
|
|
|
40 |
|
|
// Input tokens |
41 |
|
|
enum Token { |
42 |
|
|
T_NULL, // Invalid token |
43 |
|
|
T_END, // End of line |
44 |
|
|
T_NUMBER, // Hexadecimal/decimal number (uint32) |
45 |
|
|
T_STRING, // String enclosed in "" |
46 |
|
|
T_NAME, // Variable name |
47 |
|
|
T_DOT, // '.' |
48 |
|
|
T_COLON, // ':' |
49 |
|
|
T_COMMA, // ',' |
50 |
|
|
T_LPAREN, // '(' |
51 |
|
|
T_RPAREN, // ')' |
52 |
|
|
T_PLUS, // '+' |
53 |
|
|
T_MINUS, // '-' |
54 |
|
|
T_MUL, // '*' |
55 |
|
|
T_DIV, // '/' |
56 |
|
|
T_MOD, // '%' |
57 |
|
|
T_AND, // '&' |
58 |
|
|
T_OR, // '|' |
59 |
|
|
T_EOR, // '^' |
60 |
|
|
T_SHIFTL, // '<<' |
61 |
|
|
T_SHIFTR, // '>>' |
62 |
|
|
T_NOT, // '~' |
63 |
|
|
T_ASSIGN // '=' |
64 |
|
|
}; |
65 |
|
|
|
66 |
|
|
// Scanner variables |
67 |
cebix |
1.10 |
extern enum Token mon_token; // Last token read |
68 |
|
|
extern uintptr mon_number; // Contains the number if mon_token==T_NUMBER |
69 |
|
|
extern char *mon_string; // Contains the string if mon_token==T_STRING |
70 |
|
|
extern char *mon_name; // Contains the variable name if mon_token==T_NAME |
71 |
cebix |
1.1 |
|
72 |
|
|
// Streams for input, output and error messages |
73 |
|
|
extern FILE *monin, *monout, *monerr; |
74 |
|
|
|
75 |
|
|
// Current address, value of '.' in expressions |
76 |
gbeauche |
1.8 |
extern uintptr mon_dot_address; |
77 |
cebix |
1.1 |
|
78 |
cebix |
1.10 |
extern bool mon_use_real_mem; // Flag: mon is using real memory |
79 |
|
|
extern uint32 mon_mem_size; // Size of mon buffer (if mon_use_real_mem = false) |
80 |
cebix |
1.1 |
|
81 |
cebix |
1.10 |
extern bool mon_macos_mode; // Flag: enable features in the disassembler for working with MacOS code |
82 |
cebix |
1.5 |
|
83 |
cebix |
1.1 |
// Add command to mon |
84 |
cebix |
1.10 |
extern void mon_add_command(const char *name, void (*func)(), const char *help_text); |
85 |
cebix |
1.1 |
|
86 |
|
|
// Functions for commands |
87 |
cebix |
1.10 |
extern void mon_error(const char *s); // Print error message |
88 |
|
|
extern enum Token mon_get_token(); // Get next token |
89 |
|
|
extern bool mon_expression(uintptr *number); // Parse expression |
90 |
|
|
extern bool mon_aborted(); // Check if Ctrl-C was pressed |
91 |
cebix |
1.3 |
|
92 |
|
|
// Memory access |
93 |
gbeauche |
1.8 |
extern uint32 (*mon_read_byte)(uintptr adr); |
94 |
|
|
extern void (*mon_write_byte)(uintptr adr, uint32 b); |
95 |
|
|
extern uint32 mon_read_half(uintptr adr); |
96 |
|
|
extern void mon_write_half(uintptr adr, uint32 w); |
97 |
|
|
extern uint32 mon_read_word(uintptr adr); |
98 |
|
|
extern void mon_write_word(uintptr adr, uint32 l); |
99 |
cebix |
1.1 |
|
100 |
|
|
#endif |