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

# 12 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 in some ports you have to run the emulator from a terminal emulation program (such as `rxvt` or `xterm`) in order to use the monitor.

## 12.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.
``label'`
  `label` is the name of a label. It must start with a dot (".") in order for the monitor to recognize it as a label. Register names preceeded by a dot (for example `.PC`) are special labels that evaluate to value of the respective register at the time it is used, and thus can not be used as a regular label.
``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.

## 12.2 Machine state commands

`backtrace`
`bt`
  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>]`
`chis [<count>]`
  Show <count> last executed commands. (disabled by default; configure with --enable-memmap to enable)
`dump "<filename>"`
  Write a snapshot of the machine into the file specified. This snapshot is compatible with a snapshot written out by the UI. Note: No ROM images are included into the dump.
`goto <address>`
`g <address>`
  Change the PC to address and continue execution.
`io [<address>]`
  Display i/o registers. Invoking without an address shows a dump of the entire io range, if an address is given then details for the chip at the respective (base-)address are displayed (if available).
`next [<count>]`
`n [<count>]`
  Advance to the next instruction. Subroutines are treated as a single instruction.
`registers [<reg_name> = <number> [, <reg_name> = <number>]*]`
`r [<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`
`ret`
  Continues execution and returns to the monitor just after the next RTS or RTI is executed.
`step [<count>]`
`z [<count>]`
  Single step through instructions. An optional count allows stepping more than a single instruction at a time.
`stopwatch [reset]`
  Print the CPU cycle counter of the current device. 'reset' sets the counter to 0.
`undump "<filename>"`
  Read a snapshot of the machine from the file specified.

## 12.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>`
`c <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>`
`f <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>`
`h <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
`mem [<data_type>] [<address_opt_range>]`
`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>]`
`mmsh [<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`
`mmzap`
  Clear the memmap. (disabled by default; configure with --enable-memmap to enable)
`memmapsave "<filename>" <format>`
`mmsave "<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)
`memchar [<data_type>] [<address_opt_range>]`
`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.
`memsprite [<data_type>] [<address_opt_range>]`
`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>`
`t <address_range> <address>`
  Move memory from the source specified by the address range to the destination specified by the address. The regions may overlap.
`screen`
`sc`
  Displays the contents of the screen.
`sidefx [on|off|toggle]`
`sfx [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`.

## 12.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).
`disass [<address> [<address>]]`
`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.

## 12.5 Checkpoint commands

`break [load|store|exec] [address [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. The "load|store|exec" parameter can be either "load", "store" or "exec" (or any combination of these) to determine on which operation the monitor breaks. If not specified, the monitor breaks on "exec". 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>`
`cond <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>`
`del <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 [load|store|exec] [address [address] [if <cond_expr>]]`
`tr [load|store|exec] [address [address] [if <cond_expr>]]`
  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. If no addresses are given, a list of all the checkpoints is printed. The "load|store|exec" parameter can be either "load", "store" or "exec" (or any combination of these) to determine which operation the monitor traces. If not specified, the monitor traces all operations. A conditional expression can also be specified for the tracepoint. For more information on conditions, see the CONDITION command.
`until [<address>]`
`un [<address>]`
  If no address is given, the currently valid breakpoints are printed. If an address is given, a temporary breakpoint is set for that address and the breakpoint number is printed. Control is returned to the emulator by this command. The breakpoint is deleted once it is hit.
`watch [load|store|exec] [address [address] [if <cond_expr>]]`
`w [load|store|exec] [address [address] [if <cond_expr>]]`
  This command is similar to the `break` command except that it operates on watchpoints. A watchpoint differs from a breakpoint 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 checkpoints is printed. The "load|store|exec" parameter can be either "load", "store" or "exec" (or any combination of these) to determine on which operation the monitor breaks. If not specified, the monitor breaks on "load" and "store" operations. A conditional expression can also be specified for the watchpoint. For more information on conditions, see the CONDITION command.

## 12.6 General commands

`cd <directory>`
  Change the working directory.
`device [c:|8:|9:]`
`dev [c:|8:|9:]`
  Set the default address space to either the computer (`c:`) or the disk (`8:|9:`).
`dir [<directory>]`
`ls [<directory>]`
  Display the directory contents.
`pwd`
  Show current working directory.
`radix [H|D|O|B]`
`rad [H|D|O|B]`
  Set the default radix to hex, decimal, octal, or binary. With no argument, the current radix is printed.

## 12.7 Disk commands

`attach <filename> <device>`
  Attach file to device. (device 32 = cart)
`block_read <track> <sector> [<address>]`
`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.
`block_write <track> <sector> <address>`
`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>]`
`l "<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.
`list [<directory>]`
  List disk contents.
`bload "<filename>" <device> <address>`
`bl "<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>`
`s "<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>`
`bs "<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.

## 12.8 Command file commands

`playback "<filename>"`
`pb "<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>"`
`rec "<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`.

## 12.9 Label commands

`add_label <address> <label>`
`al <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 [<address_space>] <label>`
`dl [<address_space>] <label>`
  Remove the specified label from the label tables. If no address space is checked, all tables are checked.
`load_labels [<address_space>] "<filename>"`
`ll [<address_space>] "<filename>"`
  Load a file containing a mapping of labels to addresses. If no address 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 [<address_space>] "<filename>"`
`sl [<address_space>] "<filename>"`
  Save labels to a file. If no address space is specified, all of the labels are saved.
`show_labels [<address_space>]`
`shl [<address_space>]`
  Display current label mappings. If no address space is specified, show all labels from default address space.
`clear_labels [<address_space>]`
`cl [<address_space>]`
  Clear current label mappings. If no address space is specified, clear all labels from default address space.

## 12.10 Miscellaneous commands

`cartfreeze`
  Use cartridge freeze.
`cpu <type>`
  Specify the type of CPU currently used (6502/z80).
`exit`
`x`
  Leave the monitor and return to execution.
`export`
`exp`
  Print out list of attached expansion port devices.
`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.
`keybuf "<string>"`
  Put the specified string into the keyboard buffer. Note that you can specify specific keycodes by using C-style escaped hexcodes ("\x0a").
`print <expression>`
`p <expression>`
  Evaluate the specified expression and output the result.
`resourceget "<resource>"`
`resget "<resource>"`
  Displays the value of the `resource`.
`resourceset "<resource>" "<value>"`
`resset "<resource>" "<value>"`
  Sets the value of the `resource`.
`load_resources "<file>"`
`resload "<file>"`
  Load resources from `file`.
`save_resources "<file>"`
`ressave "<file>"`
  Save resources to `file`.
`screenshot "<filename>" [<format>]`
`scrsh "<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.