Go to the first, previous, next, last section, table of contents.

# 9 Monitor

Every VICE emulator has a complete built-in monitor, which can be used to examine, disassemble and assemble machine language programs, as well as debug them through breakpoints. It can be activated by using the "Activate monitor" command (left button menu). Notice that you have to run the emulator from a terminal emulation program (such as `rxvt` or `xterm`) in order to use the monitor.

Warning: this version of the monitor is still under construction, and some of the features are not fully working yet.

## 9.1 Terminology

``address_space'`
  This refers to the range of memory locations and a set of registers. This can be the addresses available to the computer's processor, the disk drive's processor or a specific memory configuration of one of the mentioned processors.
``bankname'`
  The CPU can only see 64k of memory at any one time, due to its 16 bit address bus. The C64 and other computers have more than this amount, and this is handled by banking: a memory address can have different contents, depending on the active memory bank. A bankname names a specific bank in the current address_space.
``register'`
  One of the following: program counter (PC), stack pointer (SP), accumulator (A), X register (X), or Y register (Y).
``address'`
  A specific memory location in the range $0000 to $FFFF.
``address_range'`
  Two addresses. If the second address is less than the first, the range is assumed to wraparound from $FFFF to $0000. Both addresses must be in the same address space.
``address_opt_range'`
  An address or an address range.
``prompt'`
  The prompt has the format [x:y]. If x is -, memory reads from the monitor do not have side effects. Otherwise, x is S. The second part of the prompt, y, shows the default address space.
``checkpoint'`
  The monitor has the ability to setup triggers that perform an action when a specified situation occurs. There are three types of checkpoints; breakpoints, tracepoints and watchpoints.
``breakpoint'`
  A breakpoint is triggered based on the program counter. When it is triggered, the monitor is entered.
``tracepoint'`
  Like breakpoints, a tracepoint is triggered based on the program counter. Instead of entering the monitor, the program counter is printed and execution continues.
``watchpoint'`
  Watchpoints are triggered by a read and/or write to an address. When a watchpoint is triggered, the monitor is entered.
``memmap'`
  The memmap keeps track of RAM/ROM/IO read/write/execute accesses. The feature must be enabled with "--enable-memmap" configure option, as it might decrease performance notably on slower hardware. The option also enables CPU history.
``<...>'`
  A data type.
``*'`
  Zero or more occurrences.
``[...]'`
  An optional argument.

## 9.2 Machine state commands

`backtrace`
  Print JSR call chain (most recent call first). Stack offset relative to SP+1 is printed in parentheses. This is a best guess only.
`cpuhistory [<count>]`
  Show <count> last executed commands. (disabled by default; configure with --enable-memmap to enable)
`goto <address>`
  Change the PC to address and continue execution.
`io`
  Nothing yet. Will display VIC/VIA/CIA/SID registers.
`next [<count>]`
  Advance to the next instruction. Subroutines are treated as a single instruction.
`registers [<reg_name> = <number> [, <reg_name> = <number>]*]`
  Assign respective registers. With no parameters, display register values.
`reset [<type>]`
  Reset the machine or drive. `type`: 0 = soft, 1 = hard, 8-11 = drive.
`return`
  Continues execution and returns to the monitor just after the next RTS or RTI is executed.
`step [<count>]`
  Single step through instructions. An optional count allows stepping more than a single instruction at a time.

## 9.3 Memory commands

`bank [<bankname>]`
  Without a bankname, display all available banks for the current address_space. With a bankname given, switch to the specified bank. If a bank is not completely filled (ROM banks for example) normally the `ram` bank is used where the bank has holes. The `cpu` bank uses the bank currently used by the CPU.
`compare <address_range> <address>`
  Compare memory from the source specified by the address range to the destination specified by the address. The regions may overlap. Any values that miscompare are displayed using the default displaytype.
`device [c:|8:|9:]`
  Set the default address space to either the computer `c:' or the specified drive `8:' or `9:'
`fill <address_range> <data_list>`
  Fill memory in the specified address range with the data in <data_list>. If the size of the address range is greater than the size of the data_list, the data_list is repeated.
`hunt <address_range> <data_list>`
  Hunt memory in the specified address range for the data in <data_list>. If the data is found, the starting address of the match is displayed. The entire range is searched for all possible matches. The data list may have `xx' as a wildcard.
`i <address_opt_range>`
  Display memory contents as PETSCII text.
`ii <address_opt_range>`
  Display memory contents as screen code text
`m [<data_type>] [<address_opt_range>]`
  Display the contents of memory. If no datatype is given, the default is used. If only one address is specified, the length of data displayed is based on the datatype. If no addresses are given, the 'dot' address is used.
`memmapshow [<mask>] [<address_opt_range>]`
  Show the memmap. The mask can be specified to show only those locations with accesses of certain type(s). The mask is a number with the bits "ioRWXrwx", where RWX are for ROM and rwx for RAM. Optionally, an address range can be specified. (disabled by default; configure with --enable-memmap to enable)
`memmapzap`
  Clear the memmap. (disabled by default; configure with --enable-memmap to enable)
`memmapsave "<filename>" <format>`
  Save the memmap as a picture. `format`: 0 = BMP, 1 = PCX, 2 = PNG, 3 = GIF, 4 = IFF. (disabled by default; configure with --enable-memmap to enable)
`mc [<data_type>] [<address_opt_range>]`
  Display the contents of memory as character data. If only one address is specified, only one character is displayed. If no addresses are given, the "dot" address is used.
`ms [<data_type>] [<address_opt_range>]`
  Display the contents of memory as sprite data. If only one address is specified, only one sprite is displayed. If no addresses are given, the "dot" address is used.
`move <address_range> <address>`
  Move memory from the source specified by the address range to the destination specified by the address. The regions may overlap.
`sidefx [on|off|toggle]`
  Control how monitor generated reads affect memory locations that have read side-effects, like CIA interrupt registers for example. If the argument is 'on' then reads may cause side-effects. If the argument is 'off' then reads don't cause side-effects. If the argument is 'toggle' then the current mode is switched. No argument displays the current state.
`> [<address>] <data_list>`
  Write the specified data at `address`.

## 9.4 Assembly commands

`a <address> [ <instruction> [: <instruction>]* ]`
  Assemble instructions to the specified address. If only one instruction is specified, enter assembly mode (enter an empty line to exit assembly mode).
`d [<address> [<address>]]`
  Disassemble instructions. If two addresses are specified, they are used as a start and end address. If only one is specified, it is treated as the start address and a default number of instructions are disassembled. If no addresses are specified, a default number of instructions are disassembled from the dot address.

## 9.5 Checkpoint commands

`break [<address> [if <cond_expr>] ]`
  This command allows setting a breakpoint or listing the current breakpoints. If no address is given, the currently valid checkpoints are printed. If an address is given, a breakpoint is set for that address and the breakpoint number is printed. A conditional expression can also be specified for the breakpoint. For more information on conditions, see the CONDITION command.
`enable <checknum>`
`disable <checknum>`
  Each checkpoint can be enabled or disabled. This command allows changing between these states.
`command <checknum> "<command>"`
  When checkpoint `checknum` is hit, the specified command is executed by the monitor. Note that the `x` command is not yet supported as a command argument.
`condition <checknum> if <cond_expr>`
  Each time the specified checkpoint is examined, the condition is evaluated. If it evalutes to true, the checkpoint is activated. Otherwise, it is ignores. If registers are specified in the expression, the values used are those at the time the checkpoint is examined, not when the condition is set. Currently, the cond_expr is very limited. You can use registers (.A, .X, .Y, .PC, and .SP) and compare against other registers or absolute values. For example, the following are all valid conditions: .A == 0, .X == .Y, 8:.X == .X, .A != 5, .A < .X. However, you cannot specify memory contents and compare that.
`delete <checknum>`
  Delete the specified checkpoint.
`ignore <checknum> [<count>]`
  Ignore a checkpoint after a given number of crossings. If no count is given, the default value is 1.
`trace [address [address]]`
  This command is similar to the `break` command except that it operates on tracepoints. A tracepoint differs from a breakpoint by not stopping execution but simply printing the PC, giving the user an execution trace. The second optional address can be used to specify the end of an range of addresses to be traced.
`watch [loadstore] [address [address]]`
  This command is similar to the previous two commands except that it operates on watchpoints. A watchpoint differs from the others by stopping on a read and/or write to an address or range of addresses. If no addresses are given, a list of all the watchpoints is printed. The loadstore parameter can be either "load" or "store" to determine on which operation the monitor breaks. If not specified, the monitor breaks on both operations.

## 9.6 General commands

`cd <directory>`
  Change the working directory.
`device [c:|d:]`
  Set the default memory device to either the computer (`c:`) or the disk (`d:`).
`dir [<directory>]`
  Display the directory contents.
`pwd`
  Show current working directory.
`radix [H|D|O|B]`
  Set the default radix to hex, decimal, octal, or binary. With no argument, the current radix is printed.
`sidefx [on|off|toggle]`
  Control how monitor generated reads affect memory locations that have read side-effects. If the argument is 'on' then reads may cause side-effects. If the argument is 'off' then reads don't cause side-effects. If the argument is 'toggle' then the current mode is switched. No argument displays the current state.
`system <system command>`
  Nothing yet.

## 9.7 Disk commands

`attach <filename> <device>`
  Attach file to device. (device 32 = cart)
`br <track> <sector> [<address>]`
  Read the block at the specified track and sector. If an address is specified, the data is loaded into memory. If no address is given, the data is displayed using the default datatype.
`bw <track> <sector> <address>`
  Write a block of data at `address` to the specified track and sector of disk in drive 8.
`detach <device>`
  Detach file from device. (device 32 = cart)
`@<disk command>`
  Perform a disk command on the currently attached disk image on drive 8. The specified disk command is sent to the drive's channel #15.
`load "<filename>" <device> [<address>]`
  Load the specified file into memory. If no address is given, the file is loaded to the address specified by the first two bytes read from the file. If address is given, the file is loaded to the specified address and the first two bytes read from the file are skipped. If device is 0, the file is read from the file system.
`bload "<filename>" <device> <address>`
  Load the specified file into memory at the specified address. If device is 0, the file is read from the file system.
`save "<filename>" <device> <address1> <address2>`
  Save the memory from address1 to address2 to the specified file. Write two-byte load address. If device is 0, the file is written to the file system.
`bsave "<filename>" <device> <address1> <address2>`
  Save the memory from address1 to address2 to the specified file. If device is 0, the file is written to the file system.

## 9.8 Command file commands

`playback "<filename>"`
  Monitor commands from the specified file are read and executed. This command stops at the end of file or when a STOP command is read.
`record "<filename>"`
  After this command, all commands entered are written to the specified file until the STOP command is entered.
`stop`
  Stop recording commands. See `record`.

## 9.9 Label commands

`add_label <address> <label>`
  Map a given address to a label. This label can be used when entering assembly code and is shown during disassembly. Additionally, it can be used whenever an address must be specified. <label> is the name of the label; it must start with a dot (".") in order for the monitor to recognize it as a label.
`delete_label [<memspace>] <label>`
  Remove the specified label from the label tables. If no memory space is checked, all tables are checked.
`load_labels [<memspace>] "<filename>"`
  Load a file containing a mapping of labels to addresses. If no memory space is specified, the default readspace is used. The file must contain commands the monitor understands, e.g. add_label. The compiler cc65 can create such label files. Vice can also load label files created by the Acme assembler. Their syntax is e.g. "labelname = $1234 ; Maybe a comment". A dot will be added automatically to label names assigned in this way to fit to the Vice label syntax. Normally the semicolon seperates commands but after an assignment of this kind it may be used to start a comment to end of line, so unchanged Acme label files can be fed into Vice.
`save_labels [<memspace>] "<filename>"`
  Save labels to a file. If no memory space is specified, all of the labels are saved.
`show_labels [<memspace>]`
  Display current label mappings. If no memory space is specified, show all labels.

## 9.10 Miscellaneous commands

`cartfreeze`
  Use cartridge freeze.
`exit`
  Leave the monitor and return to execution.
`help [<command>]`
  If no argument is given, prints out a list of all available commands. If an argument is given, prints out specific help for that command.
`print <expression>`
  Evaluate the specified expression and output the result.
`resourceget "<resource>"`
  Displays the value of the `resource`.
`resourceset "<resource>" "<value>"`
  Sets the value of the `resource`.
`screenshot "<filename>" [<format>]`
  Take a screenshot. `format`: default = BMP, 1 = PCX, 2 = PNG, 3 = GIF, 4 = IFF.
`tapectrl <command>`
  Control the datasette. `command`: 0 = stop, 1 = start, 2 = forward, 3 = rewind, 4 = record, 5 = reset, 6 = reset counter.
`quit`
  Exit the emulator immediately.
`~ <number>`
  Display the specified number in decimal, hex, octal and binary.

Go to the first, previous, next, last section, table of contents.