| 1 |
|
|
| 2 |
mon, Version 2.2 |
cxmon, Version 3.0 |
| 3 |
A command-driven file monitor |
A command-line file manipulation tool and disassembler |
| 4 |
|
|
| 5 |
Copyright (C) 1997-1999 Christian Bauer, Marc Hellwig |
Copyright (C) 1997-2000 Christian Bauer, Marc Hellwig |
| 6 |
Freely distributable |
GNU binutils disassemblers Copyright (C) 1988, 89, 91, 93, 94, 95, 96, 97, 1998 |
| 7 |
|
Free Software Foundation, Inc. |
| 8 |
|
|
| 9 |
|
|
| 10 |
License |
License |
| 11 |
------- |
------- |
| 12 |
|
|
| 13 |
mon is available under the terms of the GNU General Public License. See the |
cxmon is available under the terms of the GNU General Public License. See the |
| 14 |
file "COPYING" that is included in the distribution for details. |
file "COPYING" that is included in the distribution for details. |
| 15 |
|
|
| 16 |
|
|
| 17 |
Overview |
Overview |
| 18 |
-------- |
-------- |
| 19 |
|
|
| 20 |
"mon" is an interactive command-driven file manipulation tool that is inspired |
cxmon is an interactive command-driven file manipulation tool that is |
| 21 |
by the "Amiga Monitor" by Timo Rossi <trossi@jyu.fi>. It has commands and |
inspired by the "Amiga Monitor" by Timo Rossi. It has commands and features |
| 22 |
features similar to a machine code monitor/debugger, but it is not intended |
similar to a machine code monitor/debugger, but it lacks any functions for |
| 23 |
to be used for debugging. It doesn't operate on physical or virtual RAM |
running/tracing code. There are, however, built-in PowerPC, 680x0, 80x86, |
| 24 |
locations of a process but rather on a fixed-size (but adjustable) buffer with |
6502 and Z80 disassemblers and special support for disassembling MacOS code. |
| 25 |
adresses starting at 0. Also, there are no commands to trace code, set |
By default, cxmon operates on a fixed-size (but adjustable) memory buffer |
| 26 |
breakpoints etc. There are, however, built-in PowerPC, 680x0, 6502 and 8080 |
with adresses starting at 0. |
|
disassemblers. |
|
| 27 |
|
|
| 28 |
|
|
| 29 |
Installation |
Installation |
| 35 |
Usage |
Usage |
| 36 |
----- |
----- |
| 37 |
|
|
| 38 |
mon can be started from the Shell or from the Tracker (BeOS), but command line |
cxmon can be started from the Shell or from the Tracker (BeOS), but command |
| 39 |
history doesn't work when started from the Tracker). If you give no command |
line history doesn't work when started from the Tracker. |
| 40 |
line arguments, mon enters interactive mode. Otherwise, all arguments are |
|
| 41 |
interpreted and executed as mon commands. The default buffer size is 1MB. |
Options: |
| 42 |
The mon command prompt looks like this: |
-m enables symbolic MacOS A-Trap and low memory globals display in the |
| 43 |
|
680x0 disassembler |
| 44 |
|
-r makes cxmon operate in real (virtual) memory space instead of an |
| 45 |
|
allocated buffer |
| 46 |
|
|
| 47 |
|
If no additional command line arguments are given, cxmon enters interactive |
| 48 |
|
mode. Otherwise, all remaining arguments are interpreted and executed as cxmon |
| 49 |
|
commands. |
| 50 |
|
|
| 51 |
|
The default buffer size is 1MB. |
| 52 |
|
|
| 53 |
|
The cxmon command prompt looks like this: |
| 54 |
|
|
| 55 |
[00000000]-> |
[00000000]-> |
| 56 |
|
|
| 60 |
|
|
| 61 |
Commands that create a longer output can be interrupted with Ctrl-C. |
Commands that create a longer output can be interrupted with Ctrl-C. |
| 62 |
|
|
| 63 |
To quit mon, enter the command "x". |
To quit cxmon, enter the command "x". |
| 64 |
|
|
| 65 |
|
|
| 66 |
Constants, variables and expressions |
Constants, variables and expressions |
| 76 |
combinations of digits and letters (they may also start with a digit) that |
combinations of digits and letters (they may also start with a digit) that |
| 77 |
are not also valid hexadecimal numbers. Names are case-sensitive. |
are not also valid hexadecimal numbers. Names are case-sensitive. |
| 78 |
|
|
| 79 |
mon accepts expressions in all places where you have to specify a number. The |
cxmon accepts expressions in all places where you have to specify a number. |
| 80 |
following operators are available and have the same meaning and precedence as |
The following operators are available and have the same meaning and |
| 81 |
in the C programming language: |
precedence as in the C programming language: |
| 82 |
|
|
| 83 |
~ complement |
~ complement |
| 84 |
+ unary plus |
+ unary plus |
| 118 |
The buffer |
The buffer |
| 119 |
---------- |
---------- |
| 120 |
|
|
| 121 |
Those mon commands that operate on "memory" operate on a buffer allocated by |
Those cxmon commands that operate on "memory" operate on a buffer allocated |
| 122 |
mon whose size is adjustable with the "@" command. The default buffer size is |
by cxmon whose size is adjustable with the "@" command. The default buffer |
| 123 |
1MB. The buffer is an array of bytes where each byte has a 32-bit integer |
size is 1MB. The buffer is an array of bytes where each byte has a 32-bit |
| 124 |
address. Addresses start at 0 and are taken modulo the buffer size (i.e. for |
integer address. Addresses start at 0 and are taken modulo the buffer size |
| 125 |
the default 1MB buffer, addresses 0 and 100000 refer to the same byte). |
(i.e. for the default 1MB buffer, addresses 0 and 100000 refer to the same |
| 126 |
|
byte). |
| 127 |
|
|
| 128 |
The buffer is the working area of mon where you load files into, manipulate |
The buffer is the working area of cxmon where you load files into, manipulate |
| 129 |
them, and write files back from. Arbitraty portions of the buffer may be used |
them, and write files back from. Arbitraty portions of the buffer may be used |
| 130 |
as scratch space. |
as scratch space. |
| 131 |
|
|
| 133 |
Commands |
Commands |
| 134 |
-------- |
-------- |
| 135 |
|
|
| 136 |
The following commands are available in mon ('[]' marks a parameter than can be |
The following commands are available in cxmon ('[]' marks a parameter than |
| 137 |
left out): |
can be left out): |
| 138 |
|
|
| 139 |
|
|
| 140 |
x Quit mon |
x Quit cxmon |
| 141 |
|
|
| 142 |
quits mon and returns to the shell. |
quits cxmon and returns to the shell. |
| 143 |
|
|
| 144 |
|
|
| 145 |
h Show help text |
h Show help text |
| 154 |
|
|
| 155 |
ver Show version |
ver Show version |
| 156 |
|
|
| 157 |
shows the version number of mon. |
shows the version number of cxmon. |
| 158 |
|
|
| 159 |
|
|
| 160 |
? expression Calculate expression |
? expression Calculate expression |
| 178 |
of "." is set to the address after the last address displayed. |
of "." is set to the address after the last address displayed. |
| 179 |
|
|
| 180 |
|
|
| 181 |
|
b [start [end]] Binary memory dump |
| 182 |
|
|
| 183 |
|
displays the buffer contents from address "start" to address "end" in a binary |
| 184 |
|
format. Entering "b" without arguments is equivalent to "b .". The value of |
| 185 |
|
"." is set to the address after the last address displayed. |
| 186 |
|
|
| 187 |
|
|
| 188 |
m [start [end]] Hex/ASCII memory dump |
m [start [end]] Hex/ASCII memory dump |
| 189 |
|
|
| 190 |
displays the buffer contents from address "start" to address "end" as hex |
displays the buffer contents from address "start" to address "end" as hex |
| 213 |
"." is set to the address after the last address displayed. |
"." is set to the address after the last address displayed. |
| 214 |
|
|
| 215 |
|
|
| 216 |
d80 [start [end]] Disassemble 8080 code |
d80 [start [end]] Disassemble Z80 code |
| 217 |
|
|
| 218 |
disassembles the buffer contents from address "start" to address "end". |
disassembles the buffer contents from address "start" to address "end". |
| 219 |
Entering "d80" without arguments is equivalent to "d80 .". The value of |
Entering "d80" without arguments is equivalent to "d80 .". The value of |
| 220 |
"." is set to the address after the last address displayed. |
"." is set to the address after the last address displayed. |
| 221 |
|
|
| 222 |
|
|
| 223 |
d86 [start [end]] Disassemble 80x86 code (very incomplete) |
d86 [start [end]] Disassemble 80x86 (32-bit) code |
| 224 |
|
|
| 225 |
disassembles the buffer contents from address "start" to address "end". |
disassembles the buffer contents from address "start" to address "end". |
| 226 |
Entering "d86" without arguments is equivalent to "d86 .". The value of |
Entering "d86" without arguments is equivalent to "d86 .". The value of |
| 227 |
"." is set to the address after the last address displayed. |
"." is set to the address after the last address displayed. |
| 228 |
|
|
| 229 |
|
|
| 230 |
|
d8086 [start [end]] Disassemble 80x86 (16-bit) code |
| 231 |
|
|
| 232 |
|
disassembles the buffer contents from address "start" to address "end". |
| 233 |
|
Entering "d8086" without arguments is equivalent to "d8086 .". The value |
| 234 |
|
of "." is set to the address after the last address displayed. |
| 235 |
|
|
| 236 |
|
|
| 237 |
: start string Modify memory |
: start string Modify memory |
| 238 |
|
|
| 239 |
puts the specified byte string at the address "start" into the buffer. The |
puts the specified byte string at the address "start" into the buffer. The |
| 349 |
clears all currently defined variables. |
clears all currently defined variables. |
| 350 |
|
|
| 351 |
|
|
|
rmon |
|
|
---- |
|
|
|
|
|
When mon is started as "rmon", it enters "real mode". That is, all memory |
|
|
related functions no longer operate on the buffer but on "real" (virtual) |
|
|
memory. Unless you are writing Mac emulators, this is probably of not much |
|
|
use. :-) |
|
|
|
|
|
|
|
| 352 |
Examples |
Examples |
| 353 |
-------- |
-------- |
| 354 |
|
|
| 355 |
Here are some simple examples for what is possible with mon. |
Here are some simple examples for what is possible with cxmon. |
| 356 |
|
|
| 357 |
Join "file1" and "file2" to "file3": |
Join "file1" and "file2" to "file3": |
| 358 |
|
|
| 365 |
[ 0 "file" |
[ 0 "file" |
| 366 |
] 18 .-18 "file" |
] 18 .-18 "file" |
| 367 |
|
|
| 368 |
Load the mon executable and search for PowerPC "nop" commands: |
Load the cxmon executable and search for PowerPC "nop" commands: |
| 369 |
|
|
| 370 |
[ 0 "mon" |
[ 0 "cxmon" |
| 371 |
h 0 . 60,00,00,00 |
h 0 . 60,00,00,00 |
| 372 |
|
|
| 373 |
Create a modified version of mon so that the prompt has " $" instead of "->": |
Create a modified version of cxmon so that the prompt has " $" instead of |
| 374 |
|
"->": |
| 375 |
|
|
| 376 |
[ 0 "mon" |
[ 0 "cxmon" |
| 377 |
set size=. |
set size=. |
| 378 |
h 0 . "->" |
h 0 . "->" |
| 379 |
: . " $" |
: . " $" |
| 380 |
] 0 size "mon1" |
] 0 size "cxmon1" |
| 381 |
|
|
| 382 |
Convert a binary file which contains 16-bit numbers in little-endian format |
Convert a binary file which contains 16-bit numbers in little-endian format |
| 383 |
to big-endian format (or vice-versa): |
to big-endian format (or vice-versa): |
| 392 |
d 100 |
d 100 |
| 393 |
|
|
| 394 |
|
|
| 395 |
|
Using cxmon in your own programs |
| 396 |
|
-------------------------------- |
| 397 |
|
|
| 398 |
|
cxmon provides a simple interface for integration in other programs. It can, |
| 399 |
|
for example, be used as a monitor/debugger for an emulator (it is used in |
| 400 |
|
Basilisk II in this way). |
| 401 |
|
|
| 402 |
|
Here's how to do it (all functions are defined in the mon.h header file): |
| 403 |
|
|
| 404 |
|
1. Link all the cxmon object files, except main.o, to your program. |
| 405 |
|
2. In your program, call mon_init() before using any other cxmon functions. |
| 406 |
|
3. After calling mon_init(), set the mon_read_byte and mon_write_byte |
| 407 |
|
function pointers to the routines used for accessing memory. |
| 408 |
|
4. You can use mon_add_command() to add new commands to cxmon by specifying |
| 409 |
|
the command name, function and help text. From within your command |
| 410 |
|
function, you can use mon_get_token() and mon_expression() to parse the |
| 411 |
|
arguments and the mon_read/write_*() functions to access memory. |
| 412 |
|
5. To enter cxmon, call the mon() function like this: |
| 413 |
|
|
| 414 |
|
char *args[3] = {"mon", "-r", NULL}; |
| 415 |
|
mon(2, args); |
| 416 |
|
|
| 417 |
|
6. If you're done with cxmon, call mon_exit(). |
| 418 |
|
|
| 419 |
|
|
| 420 |
History |
History |
| 421 |
------- |
------- |
| 422 |
|
|