home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / programm / misc / mon154.lzh / mon.doc next >
Encoding:
Text File  |  1992-01-02  |  40.0 KB  |  1,077 lines

  1.  
  2.                  Amiga Monitor v1.54 instructions
  3.                  ================================
  4.  
  5.   This is a machine code monitor/debugger program for the Amiga.
  6.   The first version was created over 3 years ago, and many of the
  7.   features and commands of the monitor were made similar to those
  8.   of the monitors available for the Commodore 64. However, because
  9.   the Amiga is a quite different machine many new commands and
  10.   features were needed. Later versions of the monitor add many more
  11.   useful features, as expressions and variables. This version is quite
  12.   close to an actual symbolic debugger as it can read symbol table
  13.   information from executable files and display them in disassembly
  14.   listings. It also has a built-in script language.
  15.  
  16.   The monitor can be started both from CLI and from workbench. If you
  17.   want to start the monitor from workbench, you must first make an icon
  18.   for it. (starting the monitor from workbench is not recommended,
  19.   because the  programs that are run under the control of the monitor
  20.   may require the CLI environment or else they may wait for workbench
  21.   startup message forever...but you can use IconX to start the monitor
  22.   from workbench as a CLI process)
  23.  
  24.   The monitor is re-entrant (pure) code and can be made resident
  25.   (for example, using the Workbench 1.3/2.0 resident command or ARP 1.3 ares)
  26.  
  27.  
  28.   Command line arguments
  29.   ----------------------
  30.  
  31.   options:
  32.    -w <window width>
  33.    -h <window height>
  34.    -o <options>                (see 'Options Flags')
  35.    -s <initial-script-filename>        (see 'Scripts')
  36.  
  37.   An optional filename can also be given in the command line.  The monitor
  38.   will try to load the named executable file immediately after starting.
  39.   The filename must be in quotes if it contains spaces. If there is anything
  40.   on the command line after the file name, that will be used as the command
  41.   line for the program loaded to the monitor (a0/d0 registers, see @-command)
  42.  
  43.   If a '+' character is used before the filename, the monitor tries to load
  44.   symbol information from the file (see also 'l'-command).
  45.  
  46.   Using the monitor from a remote terminal
  47.   ----------------------------------------
  48.  
  49.   The monitor can be used from a terminal connected to the Amiga serial
  50.   port. If you want to do this, first set the correct baud rate and other
  51.   serial settings using the preferences program. Then mount AUX:
  52.   if necessary, and start a new CLI/Shell with the command NewShell AUX:
  53.   (or NewCLI AUX:). You get the normal CLI/Shell prompt to the terminal.
  54.   Now simply start the monitor by typing 'mon' <cr> to the terminal
  55.   (do not 'run' the monitor from the terminal; if you do it, the
  56.   monitor opens a window on the Amiga display). If the terminal is not
  57.   vt100/ansi compatible, you may need to use the 'Dumb Terminal' option
  58.   flag (flag #3) to disable some features of the monitor (such as
  59.   command line editing and history, but you can still delete the last
  60.   character with backspace/delete). Easies way to do that is to start
  61.   the monitor with the command 'mon -o4'.
  62.  
  63.  
  64.   Option flags
  65.   ------------
  66.  
  67.   Commands 'opt +n' and 'opt -n' where 'n' is a number between 1 and 3
  68.   can be used to set and reset monitor option flags. Currently three
  69.   flags is implemented:
  70.  
  71.    - flag #1
  72.       Switches on the narrow disassembly output mode
  73.       (does not show the data as hex digits)
  74.  
  75.    - flag #2
  76.       Causes characters $a0-$ff to be considered printable in
  77.       'm' command memory dump (and '?' command ascii display)
  78.       (Note that this was changed in 1.42, previously they were
  79.       printable by default).
  80.  
  81.    - flag #3
  82.       This is the 'Dumb terminal' mode flag. When this is set on,
  83.       the command line history and editing features of the monitor
  84.       are disabled, and the monitor does not use any vt100/ansi-
  85.       escape sequences.
  86.  
  87.    - flag #4
  88.       When this flag is set, the monitor echoes each command to its
  89.       output window/file before actually executing the commands.
  90.       This is mainly useful with scripts.
  91.  
  92.   Command 'opt' without parameters lists the current flag settins.
  93.   This includes a hexadecimal 'flag value' that can be used on
  94.   the command line with the '-o' option to set initial flags when the
  95.   monitor is started (That flag value is simply a bit map of the option
  96.   flags, option#1 is bit#0).
  97.  
  98.  
  99.   Input line editing and command line history
  100.   -------------------------------------------
  101.  
  102.   You can edit the input lines by using the left/right cursor keys to move
  103.   left and right, backspace to delete the character before the cursor and
  104.   del to delete the character under the cursor. You can use the up/down
  105.   cursor keys to get the old command lines (the monitor remembers 10 last
  106.   command lines). Shift-cursor-up gets the last command and enters it
  107.   automatically (you need not to press <CR>). In assembler mode you can
  108.   press Ctrl-E to edit the assembler instruction currently stored in that
  109.   address.
  110.  
  111.   These features are not available if the 'Dumb terminal' mode is
  112.   selected. In that case the only editing function is deleting the
  113.   last character with backspace or delete key.
  114.  
  115.   Stopping the output
  116.   -------------------
  117.  
  118.   In most cases the output of the monitor can be suspended by pressing SPACE
  119.   or control-S and continued by pressing control-S or SPACE again.
  120.   To permanently stop the output, press Ctrl-C.
  121.  
  122.  
  123.   Numbers
  124.   -------
  125.  
  126.   Default number base is hexadecimal but it can be changed with the ba-
  127.   command (the argument of the ba-command is always decimal).
  128.  
  129.   the prefixes used to identify number bases are:
  130.    '$'   hexadecimal
  131.    '@'   octal
  132.    '%'   binary
  133.    '_'   decimal
  134.  
  135.   Numbers can also be entered as ASCII strings, for example:
  136.    'FORM'  -->  hex 464f524d
  137.  
  138.   Note that '+' was the decimal prefix in older versions. Now it is '_'.
  139.  
  140.   Expressions
  141.   -----------
  142.  
  143.   The monitor accepts expressions in most places where you need a number.
  144.  
  145.   The calculator ('?') command allows you to directly display
  146.   values of expressions.
  147.  
  148.  
  149.   The following operators are available:
  150.  
  151.      ==  equality tese
  152.      !=  inequality test
  153.      <   less than                these tests return 1 if true and 0 if false
  154.      >   greater than             they are most useful in scripts
  155.      <=  less or equal than
  156.      >=  greater or equal than
  157.  
  158.      +   addition
  159.      -   subtraction
  160.      |   bitwise or
  161.      ^   bitwise exclusive or (xor)
  162.      &   bitwise and
  163.      *   multiplication
  164.      /   division (integer only, truncated)
  165.      %   modulo
  166.      <<  left shift
  167.      >>  right shift
  168.  
  169.   parenthesis can be used to group the operations in the expressions.
  170.  
  171.     '*'           represents the 'current address'.
  172.  
  173.     [reg_name]    represents the value of register 'reg_name'.
  174.  
  175.   All calculations are done in 32-bit integer arithmetic. No overflow
  176.   checking is done.
  177.  
  178.   Functions
  179.   ---------
  180.  
  181.   The expression parser currently accepts the following built-in functions:
  182.  
  183.    hunk(n)  --  start address of nth hunk of currently loaded seglist
  184.    hlen(n)  --  length of nth hunk of currently loaded seglist
  185.    hend(n)  --  end address of nth hunk of currently loaded seglist
  186.    nhunks   --  number of hunks in the currently loaded seglist
  187.    abs(x)   --  absolute value of a number  
  188.    peek(a)  --  8-bit contents of a memory location
  189.    peekw(a) --  16-bit contents of a memory location
  190.    peekl(a) --  32-bit contents of a memory location
  191.    avail(x) --  call AvailMem() with the argument x. for example
  192.         avail(0) returns total available memory,
  193.         avail(2) returns available chip memory
  194.         avail($20000) return largest available block.
  195.  
  196.   The following functions can be used to examine exec library, device,
  197.   resource, task and port lists. Note that the pointers returned by these
  198.   functions may become invalid any time if the library/device/task/port
  199.   is expunged/removed from the system.
  200.  
  201.   lib("libname.library")   --    returns base address of a named library or
  202.                 zero if not found. note that this does not
  203.                 try to load the library from disk, it
  204.                 only searches ExecBase->LibList.
  205.  
  206.   dev("devname.device")   --    returns base address of a named device or
  207.                 zero if not found. note that this does not
  208.                 try to load the device from disk, it
  209.                 only searches ExecBase->DeviceList.
  210.  
  211.   res("resname.resource") --    returns base address of a named resource or
  212.                 zero if not found.
  213.  
  214.   task("taskname")      --    returns pointer to named task or zero if
  215.                 not found.
  216.   task(number)          --    returns pointer to CLI process with the
  217.                 given number or zero if the CLI number
  218.                 is not in use.
  219.   task(0)          --    returns pointer to current task (the CLI
  220.                 process that runs the monitor)
  221.  
  222.   port("portname")      --    returns pointer to the public message port
  223.                 names "portname" or zero if no such port
  224.                 can be found.
  225.  
  226.   Function names are not case sensitive.
  227.  
  228.   Variables
  229.   ---------
  230.  
  231.   In addition to numbers and functions, variables can be used in expressions
  232.   if they have been previously defined. Variables are defined with the
  233.   set-command.  All variable values are 32-bit integers. Variable names can
  234.   contain alphanumeric characters and underscores ('_'), but they cannot
  235.   begin with a number. Variable names are case sensitive in this version.
  236.  
  237.   (There are some problems using variables with the assembler.
  238.   Especially variables with names starting with 'a','d' or 's' may
  239.   not be accepted in the assembler because it tries to interpret them
  240.   as register names. You can get around this by using expressions
  241.   like '0+variable')
  242.  
  243.   Byte strings
  244.   ------------
  245.  
  246.   Strings are used in the fill command, the hunt command, the modify memory
  247.   command and the assembler directive dc.b .
  248.  
  249.   Byte strings are series of bytes, represented by numbers or ASCII-
  250.   characters in single quotes or both together separated by commas.
  251.  
  252.   Note: the single quote itself may be included in a quoted string if it
  253.   is duplicated.
  254.    examples:
  255.     'this is a byte string'
  256.     12,34,56
  257.     ''''  -- this means one single quote
  258.     'both',$0A,'text',10,'and','numbers'
  259.  
  260.  
  261.   Special Note
  262.   ------------
  263.  
  264.   There is a problem with the walk (trace) command and several instructions
  265.   that cause processor exceptions. These instructions are chk, trap #n,
  266.   trapv and divu/divs (with divisions by zero). If you try to trace these
  267.   instructions, a trace-exception occurs in supervisor-mode, out of the
  268.   control of the monitor and you get a guru meditation alert with number
  269.   00000009. This problem was with the earlier monitor versions as well.
  270.  
  271.   Included with the monitor distribution is a program called patchtrace
  272.   that changes directly the processor hardware trace-exception vector to
  273.   point a new routine that removes the trap-trace problem.
  274.  
  275.   (The monitor does not support executing code in supervisor mode, so there
  276.   is not normally any reason to trace any of the instructions that can
  277.   cause problems. However, because you can accidentally cause the machine
  278.   to crash by tracing these instructions, the patchtrace-program
  279.   may be useful.)
  280.  
  281.   Stack usage
  282.   -----------
  283.  
  284.   The monitor now allocates 2K of stack for its own use and the rest
  285.   of the stack can be used by the program being debugged. If you
  286.   need a larger stack, you can use the CLI 'stack' command before you
  287.   start the monitor.
  288.  
  289.  
  290.   File/directory names
  291.   --------------------
  292.  
  293.   When the monitor requires a file or directory name or the device name
  294.   for the 'dev'-command, the name must be in quotes if it contains spaces.
  295.   This has been changed from the previous versions. Also, some escape
  296.   processign is now done to the filename strings and the arguments of
  297.   the echo-command. See the entry for echo-command for details.
  298.  
  299.  
  300.   The following commands are available in the monitor
  301.   ---------------------------------------------------
  302.  
  303. h or the HELP key on the keyboard
  304.  displays a list of commands.
  305.  
  306. i -- Info
  307.  displays a small info-message.
  308.  
  309. o -- Redirect output
  310.  usage:
  311.   o name -- redirects monitor output to file or device 'name'
  312.   o      -- returns to normal, output comes to the monitor window
  313.  For example, to send the output to printer use 'o PRT:'.
  314.  If the file specified in the 'o'-command already exists, the monitor
  315.  output will be appended to the end of the file.
  316.  
  317. ? [expr]  --  Calculator
  318.   Displays the value of the expression in hex, decimal, octal, binary
  319.   and ASCII characters.  If the number is negative, displays it as signed
  320.   and unsigned.
  321.  
  322. set [var[=expr]] -- Set/show variables
  323.   The set-command without parameters displays the values of all currently
  324.   defined variables. The form 'set var=expr' sets the value of 'var' to
  325.   the value of the expression. 'set var' removes the definition of 'var'.
  326.  
  327. cv -- Clear all variables
  328.   Asks if you really want to do it, answer 'y' to clear them.
  329.  
  330. ba [num]  --  Set/show current number base
  331.   ba without parameters displays the current number base. ba [num] sets
  332.   the base to [num] which is always decimal. this is the default base
  333.   used in number input if no base prefix is specified. initially it is 16
  334.   (hexadecimal).
  335.  
  336. mi [addr] -- Display information about memory locations
  337.   The mi-command tells you if the address 'addr' is in the system memory
  338.   list, is it allocated or not and is it inside any of the hunks
  339.   of the currently loaded segment.
  340.  
  341. m -- Display memory in hex and ASCII
  342.  Usage:
  343.   m                   -- display 20 lines from current address
  344.   m <addr>            -- display 20 lines from <addr>
  345.   m <addr> <end-addr> -- display from <addr> to <end-addr>
  346.  
  347. mf -- Formatted memory display
  348.  Usage:
  349.   mf "formatstring"
  350.   mf <addr> "formatstring"
  351.   mf <addr> <endaddr> "formatstring"
  352.  
  353.   This command displays memory in user-specified format. The format string
  354.   can contain normal text that is printed directly and c-printf-style
  355.   format specifiers. The following format specifiers are currently supported:
  356.     %b  -- display hex byte
  357.     %w  -- display hex word
  358.     %l  -- display hex longword
  359.     %db -- display decimal byte
  360.     %dw -- display decimal word
  361.     %dl -- display decimal longword
  362.     %a  -- display current address (in hex)
  363.   Also, the escape sequences described in the 'echo'-command entry
  364.   can be used in the format string.
  365.  
  366.   Note1: words and longs that are displayed must be at even addresses. If the
  367.   current address os odd when a word or longword value is going to be displayed,
  368.   the address is incremented to the next even address and an asterisk is
  369.   printed as a warning to the user.
  370.  
  371.   Note2: a space is required between this command and its arguments.
  372.  
  373. : -- Modify memory
  374.  Usage:
  375.   : <addr> <string>
  376.   Puts the <string> in memory at <addr>
  377.   This can also be done with the command 'a <addr> dc.b <string>'
  378.   (but then <addr> must be even)
  379.  
  380. f -- Fill memory with a byte or a string of bytes
  381.  Usage:
  382.   f <start-addr> <end-addr> <byte>   ;fills with <byte>
  383.   f <start-addr> <end-addr> <string> ;fills with the string
  384.  Example:
  385.   f $60000 $601FF $4E,$71 fills from $60000 to $601FF with NOP-instruction
  386.  
  387. t -- Transfer (move) memory
  388.  Usage:
  389.   t <start-addr> <end-addr> <destination-addr>
  390.  The command works correctly even if the source and destination memory
  391.  blocks overlap. (if destination is at a higher address than source,
  392.   the block is moved backwards, starting at the end)
  393.  
  394. h -- Hunt (find) string in memory
  395.  Usage:
  396.   h <start-addr> <end-addr> <string>
  397.   Displays all addresses in the range <start-addr>..<end-addr>
  398.   where the <string> is found.
  399.  
  400. c -- Compare memory
  401.  Usage:
  402.   c <start-addr> <end-addr> <string>
  403.   Displays all addresses in the range <start-addr>..<end-addr>
  404.   where is corresponding byte in the destination block is different from
  405.   the source.
  406.  
  407. a -- Assemble
  408.  usage:
  409.   a         : assemble to the current address
  410.   a <addr>  : assemble to <addr>
  411.   a <addr> <instruction> : assemble <instruction> at <addr>
  412.   After assembling an instruction the monitor prompts with the address of
  413.   the location following the instruction just assembled and waits a new
  414.   instruction to be entered. To exit this mode, simply press <CR> without
  415.   entering an instruction. To edit an existing instruction, press Ctrl-E when
  416.   the monitor is waiting an assembler instruction.
  417.  
  418.    The assembler understands all the normal 68000 instructions and also
  419.   the 'pseudo-instructions' dc.b, dc.w and dc.l, which can be used to
  420.   directly put data in memory.
  421.  
  422.  Some notes about using the assembler:
  423.  -------------------------------------
  424.    When entering assembler instructions which have an implicit size, no
  425.    size specifier is allowed in the monitor assembler. These instructions
  426.    are for example btst, bchg, bclr, btst, lea, move to/from sr/ccr/usp,
  427.    andi/ori/eori #data,sr/ccr Scc (set according to condition),
  428.    abcd/sbcd/nbcd and shifts with memory operands.
  429.  
  430.    Instructions that can have different sizes must have the size specifier,
  431.    there is no 'default size' (normal assemblers use a default size of word.
  432.    the omission of default size is intentional, because it is so easy to
  433.    forget the size specifier when you really don't mean the size to be word).
  434.  
  435.    Branch instructions with no size specifier or the .l-specifier assemble
  436.    to normal (16-bit offset) branches, if given the .s-size specifier they
  437.    assemble to the short form (8-bit offset). The dbxx-(decrement and branch)
  438.    -instructions allow no size specifier.
  439.  
  440.    The assembler converts add/sub/and/or/eor with immediate data source
  441.    automatically to adda/addi/subi/andi/eori. It does not convert move or
  442.    add/sub to the quick form nor does it convert branches automatically to
  443.    the short form. You must specify those yourself (so you must use the
  444.    moveq/addq/subq- instructions or specify the size .s to branches
  445.    as noted above). Also cmp-memory instruction must be entered as cmpm,
  446.    the assembler does not convert cmp (an)+,(an)+ to cmpm.
  447.  
  448.    The above conversion rules do not apply to andi/ori/eori with status
  449.    register or condition code register. In these cases you must enter the
  450.    instruction as andi/ori/eori (don't leave the 'i' out). Also, you
  451.    can't enter any size specifier in this case.
  452.  
  453.   (In fact I want to make the assembler more flexible than it currently is,
  454.   but that is not an easy task...maybe in some future version...)
  455.  
  456. d -- Disassemble
  457.  Usage:
  458.   d                   -- disassemble 20 lines from current address
  459.   d <addr>            -- disassemble 20 lines from <addr>
  460.   d <addr> <end-addr> -- disassemble from <addr> to <end-addr>
  461.  
  462.  If the disassembly was started inside a hunk of currently loaded executable,
  463.  it automatically stops at the end of that hunk.
  464.  
  465. r -- Show or change registers
  466.  Usage:
  467.   r        -- displays all registers
  468.   r <reg>=<number> or
  469.   r <reg> <number> -- puts the value <number> into <reg>
  470.    examples:
  471.     r D0=0
  472.     r A5 $60000
  473.  
  474. b -- Set breakpoints
  475.  Usage:
  476.   b <addr> [count] -- sets a breakpoint to <addr> with optional count
  477.    Breakpoints are implemented by putting an illegal opcode ($4AFC) in the
  478.   breakpoint locations when a G or J command is given. After returning to
  479.   the monitor the original contents of the breakpoints are restored. This
  480.   means that you can not put breakpoints to ROM (but you can trace ROM code).
  481.  
  482.   If no count is specified, default count of one is used. That means that
  483.   the execution of a program stops and control returns to the monitor
  484.   immediately when the breakpoint is encountered. If the breakpoint has
  485.   a count that is greater than one, then control returns to the monitor
  486.   when the breakpoint has been 'hit' as many times as the count is.
  487.  
  488.   Breakpoint counts do not work with the 'q' (quicktrace) command.
  489.  
  490.  
  491. br -- Remove breakpoints
  492.  usage:
  493.   br <addr> -- removes the breakpoint at <addr>
  494.   br all    -- removes all breakpoints
  495.  
  496. bl -- List breakpoints
  497.  Usage:
  498.   bl -- display a list of all breakpoints.
  499.  
  500. The g, j, w, q and e-commands use the current program counter value
  501. (displayed with the r-command) if you don't give them an address.
  502. The stack pointer is reset and a return address to the monitor is
  503. put in the stack if the stack pointer is out of range.
  504.  
  505. g [addr] -- Go (execute machine code)
  506.  
  507. j [addr] -- Jump to subroutine
  508.  As g-command but pushes return address first. this return address will
  509.  give control back to the monitor when rts-instructions is executed.
  510.  
  511. w [addr] -- Walk (single step trace)
  512.  This single steps code using the 68000 processor built-in trace mode.
  513.  It works even with ROM code (but the e-command doesn't).
  514.  
  515.  (This command does not activate breakpoints)
  516.  
  517. e [addr] -- Extended trace (execute with temporary breakpoint)
  518.  This command allows you to execute subroutine calls in full speed
  519.  when tracing and you don't need to manually place a breakpoint after
  520.  the calls. when the e-command is executed, a temporary breakpoint is
  521.  placed in the location after the instruction to be executed. this break-
  522.  point is automatically removed after the control returns to the monitor.
  523.  
  524.  The e-command can be used instead of the w-command to trace most of the
  525.  instructions, but it is recommended that you use the w-command for
  526.  tracing and when tracing code until you get to a subroutine call
  527.  instruction. then enter the e-command and the subroutine is executed
  528.  normally, but after that the monitor interrupts execution to the
  529.  invisible breakpoint.
  530.  
  531.  Note that if you use the e-command in an address that contains a flow-
  532.  control instruction, the code flow may never come to the temporary
  533.  breakpoint. Normally it is better to trace using the w-instruction,
  534.  but for example, system calls cannot always be traced, and even if
  535.  they can, you most probably don't want to do it. In previous versions
  536.  of the monitor you had to manually insert a breakpoint after the call
  537.  and use the g-command. Now you can simply use the e-command.
  538.  
  539. q [addr] -- QuickTrace (execute until flow-control instruction)
  540.  This command executes code one instruction at time (in the 68000 trace mode)
  541.  until it encounters a program flow control instruction (jump, branch,
  542.  subroutine call or return, trap).
  543.  
  544. z -- skip current instruction
  545.  This command can be used to advance the PC register over one instruction.
  546.  Note that this does not actually execute or trace code, it only changes
  547.  the monitor internal register values. An address can also be given as
  548.  a parameter to this command but it is normally not useful (the current
  549.  PC value will normally be used).
  550.  
  551. Note: there is no easy way to run BCPL programs (CLI commands) or other
  552. programs that use the internal BCPL library from the monitor.
  553.  
  554. @ -- Enter command line
  555.  Usage:
  556.   @ [command line]. If you don't specify a command line (enter only @<cr>)
  557.   then the monitor will prompt for command line. The command line will
  558.   be put in a special memory area and the register a0 will contain pointer
  559.   to the string and d0 will contain length of the string (with a linefeed
  560.   appended to end of it). If you want an empty command line, enter the
  561.   @-command without parameters and press return on the 'Cmdline>'-prompt.
  562.   The purpose of this command is to specify a command line for the program
  563.   that you are running from the monitor. If you start the monitor with a
  564.   filename, anything after the filename is automatically used as the
  565.   command line.
  566.  
  567.  
  568. l -- Load segment
  569.  Usage:
  570.   l [+] <name> -- loads the executable file <name> in memory and displays
  571.     the starting address of the first hunk, also sets PC to this address.
  572.    only one executable file be loaded at the same time. Before loading a
  573.   new file you must unload the old file with the u-command.  To display
  574.   the starting & ending addresses of all the hunks in the file, use the
  575.   sl-command.
  576.  
  577.   Command 'l + <name>' loads symbol table and hunk type information in
  578.   addition to the actual file hunks. Those symbols are like the variables
  579.   defined by 'set' command, but they also have a hunk number associated with
  580.   them (it shows in square brackets in the 'set' listing). Also, the symbols
  581.   are automatically removed when the file is unloaded with the 'u'-command.
  582.  
  583.   Overlays are not supported.
  584.  
  585. u -- Unload segment
  586.  Usage:
  587.   u  -- unload the currently loaded executable file.
  588.         symbol information loaded by 'l +' is removed by this command.
  589.  
  590. sl -- Segment list
  591.  Usage:
  592.   sl -- displays the starting & ending addresses and length of each hunk
  593.   of the currently loaded file. If the 'l +' command has been used to
  594.   load the file, also the type of each hunk is displayed (including chip/fast
  595.   memory types and data/bss byte counts of split data/bss hunks).
  596.  
  597. rb -- set base address for address register relative symbols
  598.  Usage:
  599.   rb addr  --    sets base address of a4-relative addressing to addr. typically
  600.                  this is in the beginning of the data hunk of a program with
  601.                  programs compiled with Lattice/SAS C.
  602.   rb addr reg -- as above but allows selection of address register
  603.                  other than a4.
  604.   rb 0     --    removes the base address setting.
  605.   rb       --    displays current base address setting.
  606.  
  607.   When the base address setting is active, the disassembler will check all
  608.   xx(a4) (or other addr reg, if selected) addressing modes and if
  609.   baseaddr + offset equals a symbol, the symbol is displayed.
  610.  
  611. ( -- Allocate memory
  612.  Usage:
  613.   ( <length>        -- allocate <length> bytes any type of memory
  614.   ( <length> C      -- allocate <length> bytes of chip memory
  615.   Displays the start & end addresses of the allocated memory block.
  616.  
  617. & -- Allocate absolute memory location
  618.  Usage:
  619.   & <addr> <length> -- allocate <length> bytes at <addr>
  620.  
  621. ) -- Free memory
  622.  Usage:
  623.   ) <addr> -- frees the memory block starting at <addr>
  624.   ) all    -- frees all the memory allocated with the (- and &-commands
  625.  
  626. sm -- Show allocated memory
  627.  Usage:
  628.   sm -- display all memory blocks allocated with the (- and &-commands
  629.  
  630. [  -- Read file
  631.  Usage:
  632.   [ <addr> <name> -- reads the file <name> to memory starting at <addr>
  633.  
  634. ]  -- Write file
  635.  Usage:
  636.   ] <addr> <length> <name> -- creates a file named <name> and writes <length>
  637.  bytes of memory starting at <addr> to the file.
  638.  
  639. dev -- set/show current disk device
  640.  Usage:
  641.   dev  --  show current disk device
  642.   dev devname -- set current disk device
  643.  
  644.  devname is an exec device name, given without quotes and with the '.device'-
  645.  suffix. for example, if you have a 2090 hd controller, you can
  646.  set it as the default disk device with the command: dev hddisk.device
  647.  Note that the disk read/write commands work in the exec device level and
  648.  know nothing about hard disk partitions. Be careful if you use the monitor
  649.  to edit hard disk sectors! Note also that actual disk IO buffers used by
  650.  the monitor are always in chip memory.
  651.  
  652.  The current disk device is used by the '<' and '>'-commands.  Previous
  653.  versions of the monitor had them hardwired to use trackdisk.device.
  654.  
  655. <  -- Read disk sectors
  656.  Usage:
  657.   < <addr> <unit> <start-sector> <number-of-sectors>
  658.  Reads <number-of-sectors> sectors from the disk in unit <unit> to memory
  659.  starting at <addr>. <unit> is the unit number to be used in OpenDevice().
  660.  with the default device (trackdisk.device) units 0..3 correspond DOS
  661.  devices DF0: -- DF3:
  662.  
  663.  the read destination address does not need to be in chip memory.
  664.  
  665. >  -- Write disk sectors
  666.  Usage:
  667.   > <addr> <unit> <start-sector> <number-of-sectors>
  668.  Writes <number-of-sectors> sectors to the disk in unit <unit> from memory
  669.  starting at <addr>. <unit> is the unit number to be used in OpenDevice().
  670.  with the default device (trackdisk.device) units 0..3 correspond DOS
  671.  devices DF0: -- DF3:
  672.  
  673.  the write source address does not need to be in chip memory.
  674.  
  675. =  -- Corrects a disk block checksum
  676.  Usage:
  677.   = <addr> -- if there is a DOS-format disk block read into memory at <addr>,
  678.  calculates the correct checksum for the block and stores it in the block.
  679.  Displays old and new checksums. This command is useful if use use the
  680.  monitor as a disk editor. Addr must be even.
  681.  
  682.  Extended usage: = <addr> <len> <offs>
  683.  where <len> is block length to be checksummed and <offs> is the offset
  684.  of the checksum longword from the start of the block. The checksum is
  685.  calculated to that the sum of the longwords in the block is zero.
  686.  
  687.  Checksum for hard disk RigidDiskBlocks can be calculated with:
  688.  = <addr> $100 $08
  689.  
  690.  
  691. #  -- Corrects bootblock checksum
  692.  Usage:
  693.   # <addr> -- if there is a disk bootblock (2 disk blocks, 1024 bytes) read
  694.  into memory at <addr>, calculates a new checksum for the bootblock and stores
  695.  it in the bootblock (in memory). Displays old and new checksums.
  696.  Addr must be even.
  697.  
  698.  Extended usage: # <addr> <len> <offs>
  699.  where <len> is block length to be checksummed and <offs> is the offset
  700.  of the checksum longword from the start of the block. The checksum is
  701.  calculated to that the sum of the longwords with carry in the block
  702.  is $ffffffff.
  703.  
  704.  Checksum for pre-2.0 kickstart images can be calculated with:
  705.  # <addr> $40000 $3ffe8
  706.  and for 2.0 kickstart images with:
  707.  # <addr> $80000 $7ffe8
  708.  
  709. !  -- Play digisound
  710.  Usage:
  711.   ! <addr> <length> <period> [<count>]
  712.  Plays sound <length> bytes starting at <addr> and using sampling period
  713.  <period>. the sound repeats <count> times or until you stop it by
  714.  pressing Ctrl-C. <addr> must be in CHIP memory!.
  715.  
  716. cls -- Clears the monitor window
  717.  
  718. del <filename> -- Deletes a file
  719.  
  720. cd  <dirname>  -- Sets the current directory
  721.  
  722. dir [<name>]   -- Displays the directory
  723.   if you don't specify the name, then current directory
  724.   will be displayed.
  725.  
  726. \ -- Command/ New Shell
  727.   Usage:
  728.    \ shell_command  -- executes one shell command
  729.    \                -- starts new shell with 'NewShell' or 'NewCLI'
  730.   This uses the AmigaDOS Execute() call on 1.3, so it requires the 'Run'-
  731.   command to be in the C:-directory in AmigaDOS versions before 1.3.2
  732.   (on AmigaDOS 2.0 it uses the new System() call)
  733.  
  734. vt -- show tasks
  735.   Shows the addresses, types, states and priorities of all tasks currently
  736.   in the system (on the exec TaskWait & TaskReady lists and the current task)
  737.  
  738.   Type: t - task, p - process, c - CLI process
  739.   State: w - waiting, r - ready, c - current
  740.  
  741. vl -- show library list
  742.   Shows the addresses, names, versions & revisions and open counts of
  743.   all libraries on the exec library list.
  744.  
  745. vd -- show device list
  746.   Shows the addresses, names, versions & revisions and open counts of
  747.   all devices on the exec device list.
  748.  
  749. vr -- show resource list
  750.   Shows the addresses and names of all resources on the exec resource list.
  751.  
  752. vp -- show port list
  753.   Shows the addresses, SigBits, mp_Flags-fields and names of all public
  754.   message ports currently in the system.
  755.  
  756. vs -- show semaphore list
  757.   Shows the addresses and names of all public signalsemaphores currently
  758.   in the system.
  759.  
  760. echo -- display text and/or numbers
  761.   Usage:
  762.     echo string | [$][expr] [string | [$][expr] ...]
  763.  
  764.   Writes the string(s) given in the command to the monitor output window/file.
  765.   strings can be quoted with double quotes. Also, the '\'-character is used
  766.   as an escape character. The following escape sequences are available:
  767.  
  768.    \n -> newline/linefeed
  769.    \r -> carriage return
  770.    \t -> tabulator
  771.    \e -> the ASCII Escape character (0x1b, 27 decimal)
  772.    \\ -> '\'
  773.    \xnn where nn are hex digits -> ascii code nn
  774.  
  775.   These escape sequences can also be used whenever file names are given
  776.   to the monitor.
  777.  
  778.   Numbers/expressions can be output by putting them in square brackets.
  779.   [expr]  -- displays expression in decimal
  780.   $[expr] -- displays expression in hexadecimal
  781.  
  782.   The echo-command is most useful in script files.
  783.  
  784. exec -- execute a script file
  785.   Usage:
  786.     exec filename
  787.  
  788.   Executes the given script file. for more information, see 'Scripts' below.
  789.  
  790. poke, pokew, pokel  --  write to memory
  791.  
  792.   poke <addr> <byteval>
  793.   pokew <addr> <wordval>
  794.   pokel <addr> <longval>
  795.  
  796.   Similator to corresponding BASIC commands. These commands write data to
  797.   a memory location. Poke writes a byte (8-bit), pokew writes a word (16-bit)
  798.   and pokel writes a longword (32-bit). Note that there is no comma between
  799.   the address and value parameters.
  800.  
  801. x -- Exit
  802.   Cleanup and exit the monitor. This frees all the memory allocated
  803.   with ( and & commands and closes redirection file, if open.
  804.  
  805.  
  806. Scripts
  807. -------
  808.  
  809.   The Amiga monitor versions 1.52 and above has a built-in script language.
  810.   All normal monitor commands can be executed from scripts, and the are
  811.   additional commands for controlling script execution.
  812.   Scripts are started with the 'exec' command that can also be used inside
  813.   scripts, so scripts can be nested (and memory availability is the only
  814.   limit of the nesting depth).
  815.  
  816.   All lines in a script file beginning with a semicolon (;) are treated as
  817.   comments and ignored by the monitor.
  818.  
  819. Script control commands
  820. -----------------------
  821.  
  822. quit -- quit executing a script and return to the previous script or
  823.         keyboard input.
  824.  
  825. goto label  --  go to a specified label in a script.
  826.         Labels must be in the beginning of a line, and begin with a period (.)
  827.         An optional colon can be in the end of the label name. The period
  828.         and colon are not actually parts of the label name, so they are
  829.         not included in the goto-command.
  830.  
  831.  Example:
  832.  
  833.    goto foobar
  834.    ... other script commands
  835.  
  836. .foobar:    echo "This is the label 'foobar'"
  837.  
  838. if <expr> <command> -- conditional execution
  839.         Executes the single <command> only when expression <expr> is non-zero.
  840.         More complex conditionals can be constructed by using if and goto
  841.         together.
  842.  
  843.   Example:
  844.  
  845. set counter = 1
  846. .loop
  847. echo "counter is" [counter]
  848. set counter=counter+1
  849. if counter <= _10 goto loop
  850.  
  851. Version history:
  852. ----------------
  853. 1.54 ->
  854.  - added poke[w,l] commands
  855.  
  856. 1.53 ->
  857.  - better error reporting with scripts.
  858.  
  859. 1.52 ->
  860.  - scripts (exec/quit/if/goto/echo commands)
  861.  - \-command can be used to execute any cli/shell command.
  862.  
  863. 1.51 ->
  864.  - no longer lists bss hunks as split in strange ways (one lsl.l #2,d0 was
  865.    missing in version 1.50)
  866.  
  867. 1.50 ->
  868.  - now mf-command requires space after command, else -> m fxxxx
  869.  - show seglist displays info about split data/bss hunks
  870.  - internal source reorganization
  871.  
  872. 1.49 ->
  873.  - hunk type display also shows chip/fast
  874.  - some changes in symbol handling
  875.  - internal source reorganization
  876.  - disassembly stops at hunk end
  877.  
  878. 1.48 ->
  879.  - address register relative symbol support (rb-command)
  880.  
  881. 1.47 ->
  882.  - symbol support
  883.  - variables now case sensitive
  884.  - hunk type display in 'sl'-command
  885.  
  886. 1.46 ->
  887.  - added breakpoint counts.
  888.  
  889. 1.45 ->
  890.  - small change in help text.
  891. 1.44 ->
  892.  - added task/library/device/resource/port/semaphore list viewing commands.
  893.  
  894. 1.43 ->
  895.  - added formatted memory dump command
  896.  - now gives error message if cannot allocate audio channels in digisound
  897.    play command.
  898.  - display can be stopped/started with ctrl-s/ctrl-q
  899.  - spaces can be used in 'set register' command before the equal sign.
  900.  
  901. 1.42 ->
  902.  - better option handling
  903.  - understands 2.0 shell window close gadget
  904.  - redirection to file now appends if possible
  905.  - modulo operator now '%'
  906.  
  907. 1.41 ->
  908.  - fixed a bug that prevented some assembler instructions working.
  909.  
  910. 1.40 ->
  911.  - cd works correctly again
  912.    (in 1.37..1.39 it ignored first letter of dir name...)
  913.  
  914. 1.39 ->
  915.  - interrupting 'c' or 'h' commands no longer causes error conditions.
  916.  - added option flag 2 to select whether characters $a0-$ff are printable
  917.    in 'm' command memory dump.
  918.  
  919. 1.38 ->
  920.  - return from 'j' or 'g' commands with rts now works (was a major bug in 1.37)
  921.  - input routine no longer acts strangely if shift-cursor-down
  922.    or ESC-cursor/function/help is pressed.
  923.  - command line automatically set if file name given on the monitor command
  924.    line.
  925.  - many little changes in assembler. most of these not visible to the user.
  926.  
  927. 1.37 -> lots of new features...
  928.  - major source code reorganization
  929.  - extended checksum commands
  930.  - calculator 'ascii' output
  931.  - memoryinfo displays hunk offsets
  932.  - breakpoint numbers
  933.  - added 'port()' to expression parser
  934.  
  935. 1.34 ->
  936.  - added 'narrow disassembly' option.
  937.  - digisound player now defaults to play the sample once.
  938.  
  939. 1.32 ->
  940.  - now opens own window only if started with 'run' or window width and
  941.    height are given on the command line. can be used from serial terminal
  942.    with AUX: shell.
  943.  
  944. 1.31 ->
  945.  - it is now not possible to accidentally try to assemble code to
  946.    an odd address.
  947.  
  948. 1.30 ->
  949.  - many internal changes: global variable base register changed, uses
  950.    new library call macros...
  951.  
  952. 1.29 ->
  953.  - added lib(), dev(), res() and task() to expression parser.
  954.  
  955. 1.28 ->
  956.  - modified patchtrace to work also when vector base is relocated.
  957.  - small changes in initial window placement and size
  958.  
  959. 1.27 ->
  960.  - disk block/bootblock checksum functions and jump/go/trace etc. now
  961.    check properly for odd addresses.
  962.  - 'odd address'-error message
  963.  - skip instruction-command
  964.  - Exit() now returns control back to the monitor.
  965.  
  966. 1.26 ->
  967.  - added hend() and nhunks-functions to the expression parser.
  968.  - added command line options for window width and height
  969.  - a file name to LoadSeg() can be given in the command line
  970.  - new filename parse routine, now names with spaces in
  971.    them must be in quotes
  972.  
  973. 1.25 ->
  974.  - (internal change) now uses TC_Userdata instead of TC_TrapData because
  975.    TC_TrapData is marked as private in some prerelease 1.4/2.0 includes.
  976.  - '\'-command now first tries to start a shell, then a CLI.
  977.  - disk read/write commands can be used with hard disks etc.
  978.  - fixed condition code register setting with go and jump commands.
  979.  
  980. 1.24 ->
  981.  - corrected a small bug in the assembler/disassembler mnemonic tables
  982.    (trap and tas-instructions were accidentally exchanged...)
  983.  
  984. 1.23 ->
  985.  - quicktrace-command
  986.  - now reserves separate areas of stack for the monitor itself and
  987.    the program being debugged.
  988.  
  989. 1.22 ->
  990.  - better handling of stack pointer with jump & go-commands
  991.  - extended trace command
  992.  - memory display can be used at odd addresses
  993.  - generally cleaned up the source code
  994.  - variables are now case-insensitive.
  995.  
  996. 1.20 ->
  997.  - added the '[register]'-syntax in the expression parser
  998.  
  999. 1.19 ->
  1000.  - disassembler now uses new routines. this makes the monitor
  1001.    executable little smaller than 1.17
  1002.  
  1003. 1.17 ->
  1004.  - monitor is now re-entrant and can be made resident
  1005.  - transfer no longer crashes if you transfer from location zero
  1006.  - default base is again hexadecimal
  1007.  
  1008. 1.15 ->
  1009.  - some minor bug fixes in assembler
  1010.    (move sp,usp or exg Rx,sp did not work)
  1011.  - 'memory info'-command
  1012.  - underscores are allowed in variable names
  1013.  - variable list is kept in alphabetical order
  1014.  
  1015. 1.12 ->
  1016.  - expressions can now be used instead of numbers. also included
  1017.    calculator-command.
  1018.  - variables can be used in expressions.
  1019.  - user-defineable default number base, default is now decimal.
  1020.  - hunt-command no longer finds anything in the monitor code/data areas
  1021.  - show seglist now displays hunk numbers
  1022.  - chip memory allocation syntax has been changed.
  1023.  
  1024. 1.08 ->
  1025.  - the monitor works ok with 68010/68020 processors. previous versions
  1026.    left sometimes extra data in supervisor stack.
  1027.  
  1028. 1.07 ->
  1029.  - The disassembler and assembler handle exg Dn,An correctly
  1030.    (previously the data and address register numbers were reversed)
  1031.  - The disassembler no more displays any invalid codes as valid
  1032.    instructions (On the 68000 processor, of course. The monitor does
  1033.    not currently support 68010/68020 extra instructions).
  1034.  - The pc-relative indexed addressing mode now works with the assembler.
  1035.  - Some little bugs were fixed in the assembler.
  1036.     + And/or-instructions work with a pc-relative source operand. 
  1037.     + cmpm works with all sizes
  1038.     + most(if not all...) of the bugs that caused the assembler to
  1039.       assemble invalid instructions have been fixed.
  1040.  - 'sp' can be used instead of 'a7' in the assembler and the disassmbler
  1041.    displays a7 as 'sp'.
  1042.  - The assembler now unserstands blo/bhs, slo/shs and dblo/sbhs
  1043.    and assembles them as bcs/bcc, scs/scc and dbcs/dbcc
  1044.  - The disassembler displays address-register relative offsets and short
  1045.    absolute addresses as signed numbers.
  1046.  - The monitor works now better with 60-column default font (TOPAZ60).
  1047.  - Disk read/write commands can be used with non-chip memory
  1048.  - Play digisound command has an optional parameter to specify
  1049.    how many times the sample is played.
  1050.  - A new command has been added to specify a command line for programs
  1051.    executed under the control of the monitor.
  1052.  - Breakpoints work even if you jump into the code at to breakpoint.
  1053.    The breakpoint does not activate until the instruction at the break
  1054.    position is executed, so you don't get immediately interrupted.
  1055.    (internally the monitor uses the trace-exception to skip the breakpoint
  1056.    at the first time...)
  1057.  
  1058. 1.06 and older...
  1059.  - prehistoric versions...
  1060.  
  1061.  
  1062.   Amiga Monitor v1.54 Copyright ⌐ 1987-1991 by Timo Rossi. The monitor
  1063. can be freely distributed non-commercially. This document file and the
  1064. 'patchtrace'-program should be included in the distribution. Preferred
  1065. way of distribution is the lharc-archive 'mon154.lzh'.
  1066.  
  1067.   Special Permission is given to Fred Fish to distribute this program on
  1068. his 'Fish disks'.
  1069.  
  1070. Send suggestions, bug reports etc. to:
  1071.  
  1072.   Timo Rossi
  1073.   Kellankoski            E-mail:
  1074.   44300 Konnevesi        trossi@jyu.fi
  1075.   FINLAND
  1076.  
  1077.