home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Basic / MAXONB32.DMS / in.adf / docs.lha / Debugger < prev    next >
Encoding:
Text File  |  1994-10-31  |  71.7 KB  |  2,378 lines

  1.  
  2. The Debugger
  3.  
  4.  
  5. Introduction
  6.  
  7. Programming mistakes (known as bugs, after a
  8. spider that was found crawling around the core
  9. memory of one of the early computers) can range
  10. from the trivial, such as a missing linefeed in
  11. a printout, through the usual (an incorrect
  12. result) to the very serious where the computer
  13. crashes because you have used the wrong pointer
  14. or corrupted the system memory (like that
  15. spider).
  16. To help you find and correct all forms of bugs,
  17. MaxonBASIC includes a debugger, MonAm. MonAm is
  18. a powerful symbolic debugger and disassembler
  19. which lets you examine programs and memory,
  20. execute programs an instruction at a time and
  21. trap processor exceptions caused by programmer
  22. error.
  23. MonAm uses its own screen (in the Amiga¨
  24. sense), so if you are debugging a program which
  25. uses windows, your program will not be sent re-
  26. draw messages or have its display destroyed
  27. when you single-step or breakpoint. This makes
  28. it particularly useful for graphical output
  29. programs such as applications running under
  30. Intuition.
  31. If you are already an expert from using MonAm
  32. supplied with Devpac Amiga version 3, please
  33. read the next few pages on the use of MonAm
  34. with MaxonBASIC. Devpac 2 users should note
  35. that many new features have been added to
  36. version 3 of the debugger.
  37.  
  38.  
  39. Debugging BASIC Programs
  40.  
  41. Although MonAm is a low-level debugger,
  42. displaying such things as 680x0 instructions
  43. and registers, it can be used to good effect
  44. for debugging programs written with any
  45. compiler that generates machine-code output
  46. such as MaxonBASIC. You will see sub-program
  47. and function names within the code and you can
  48. view your original source and step through it
  49. by line etc.
  50. However, in order to make use of the debugger
  51. and to understand this section of the manual
  52. you should have at least a basic knowledge of
  53. assembly language. It is not intended for the
  54. beginner.
  55. In order to use the debugger fully with
  56. MaxonBASIC programs you must remember to enable
  57. both the Line Debug (either compressed or
  58. standard) and Debugging Symbols options. Note
  59. that this does not give you access to local
  60. variables. In general it is easier to debug
  61. programs that do not use the BASIC shared
  62. library since the debugger will then give the
  63. names of the runtime routines.
  64. One thing to consider before groping around
  65. inside your program with MonAm is that many
  66. bugs can be discovered much more easily by
  67. simply looking at the source code. Take some
  68. time to explore the problem and then carefully
  69. study the parts of the program likely to
  70. produce such results. Using this method of
  71. debugging you are much more likely to spot
  72. structural errors or find a better way of doing
  73. something rather than simply patching up the
  74. problem.
  75.  
  76.  
  77. Program initialisation
  78.  
  79. Before your BASIC program starts executing, a
  80. number of initialisation procedures will be
  81. called. These include the startup code which
  82. handles CLI or Workbench startup with
  83. parameters, heap and run-time initialisation.
  84. Your program will start at label REF0001.
  85. You can use the Run Until command and simply
  86. enter #1 which will run until the first line of
  87. your program. Alternatively you may wish to run
  88. until a certain line number in your source
  89. file.
  90.  
  91.  
  92. Source files
  93.  
  94. MonAm is able to understand line number
  95. debugging information so that it ´knows´ where
  96. in memory each program line starts and can
  97. automatically load your source code for you.
  98. Using these facilities, the debugger will
  99. ´track´ the source code correctly showing both
  100. the current instruction in a disassembly and
  101. the corresponding line of BASIC.
  102. By default, MonAm attempts to load the program
  103. source for you (although you may disable this
  104. via the Preferences command). For many
  105. programs, you need not worry about multiple
  106. source files but when working on a larger
  107. program which is divided into a number of
  108. source files you will want access to each one.
  109. You may load further source files from disk by
  110. selecting the appropriate window and using the
  111. Load ASCII command (Ctrl-A). If any line number
  112. debugging was generated for the file it will
  113. also be ´locked´ to the program counter so that
  114. it is tracked automatically. When control
  115. switches between source files (calling a
  116. procedure in another unit, for example) it is
  117. up to you to flip between them using the . and
  118. , keys.
  119. When a source file is loaded, you may line
  120. numbers with all of the debugger commands
  121. through two special operators; # and ?. The
  122. first of these yields a program address, so
  123. placing a breakpoint at #10 puts a breakpoint
  124. at line 10. The expression #0 is taken to mean
  125. the first executable line of code. The second,
  126. less frequently used operator does the
  127. opposite, returning you the line number
  128. corresponding to a given program address.
  129.  
  130.  
  131. Variables
  132.  
  133. Although there are no facilities for displaying
  134. a particular Pascal variable it is quite
  135. possible to examine or even change the values
  136. of program variable. All global variables are
  137. given a label name so that typing their name
  138. will return the address at which they are
  139. stored in memory, not their value. Setting a
  140. window start address to a variable name will
  141. allow you to view and edit that memory.
  142.  
  143.  
  144. Understanding the generated code
  145.  
  146.  
  147. The easiest way to find the machine code that
  148. corresponds to a line in your BASIC program and
  149. vice versa is with the debuggers # and ?
  150. operators. If you have used the Add Error Line
  151. Numbers (LINES) option you will see lines of
  152. code such as:
  153.  
  154.  
  155.  move.l  #$AAAABBBB,(A5)
  156.  
  157.  
  158. at the beginning of the code for each line. The
  159. hex number AAAA is the physical line number
  160. i.e. the line number displayed by the editor,
  161. while the hex number BBBB is the last actual
  162. line number given in the source.
  163. If you have Event checks switched on you will
  164. also see a line like this:
  165.  
  166.  
  167.  jsr $14(A5)
  168.  
  169.  
  170. at the start of each line. This is the code
  171. that checks to see if an event has occurred.
  172.  
  173. To find the value of a global variable find a
  174. line when its value is set. The code for this
  175. line will finish by storing its value via an
  176. offset from A5. For example,
  177.  
  178.  
  179.  a%=42
  180.  
  181.  
  182. might generate
  183.  
  184.  
  185.  move.w  #$2A,$E78(a5)
  186.  
  187.  
  188. Here $2A is 42 in hexadecimal. The variable a%
  189. will be stored at address a5+$E78.
  190.  Setting a window start address to a variable
  191. name will allow you to view and edit that
  192. memory.
  193. When interpreting the data you are looking at
  194. you must bear in mind the format in which the
  195. variable is stored, whether it is a integer, or
  196. long integer or string for example. See
  197. Appendix G for further details.
  198. A quicker way to examine a numeric variable´s
  199. value without upsetting your window display is
  200. to use the Other Bases command by simply
  201. pressing O. Something similar to the following
  202. line can then be entered:
  203.  
  204.  
  205.  {a5+E78}.w
  206.  
  207.  
  208. This would display the word (omitting the
  209. extension shows a longword) stored in counter
  210. in both decimal and hex.
  211. Note that Mon also ´understands´ about the way
  212. that MaxonBASIC deals with in-line strings.
  213. These are really a subroutine call (to
  214. str_constant) followed by the length of the
  215. string and its actual data. Fortunately this is
  216. disassembled as:
  217.  
  218.  
  219.  string  "data"
  220.  
  221.  
  222. so that you may just skip over it using Ctrl-T.
  223. Also, note that you may see NOP instructions
  224. within the compiled code; don´t be alarmed.
  225. These are produced by the code generator
  226. because on its first pass it leaves room for a
  227. JMP absolute instruction when program flow
  228. changes, but on pass 2 it notices that the
  229. destination is within range for a four byte
  230. BRA, so it has to add the NOP (it does not
  231. optimise to BRA.S as these take the same time
  232. to execute). As the NOPs never get executed
  233. there is no speed penalty, but there is a size
  234. increase. This is worthwhile; the result is
  235. that there are no size limits on compiled
  236. programs.
  237.  
  238.  
  239. Termination
  240.  
  241. You will normally want to run the program until
  242. you detect certain conditions or an exception
  243. occurs. In many cases you can just return
  244. control to the program with Ctrl-R and allow it
  245. to terminate normally. However, sometimes this
  246. is not possible.
  247. If the program is about to do something wrong,
  248. such as pass the incorrect value or use an
  249. uninitialised pointer, you may be able to
  250. manually adjust the values so that it works
  251. correctly. If you want to abandon the program
  252. you can just quit MonAm which will leave the
  253. program in memory in a halted state.
  254. If you wish to exit more cleanly then you
  255. should resume execution from the label System
  256. which is effectively like executing a BASIC
  257. SYSTEM statement. This may leave some resources
  258. lying around but it will terminate the program,
  259. allowing you to continue with further
  260. compilations etc. Note however that if the A5
  261. or A3 registers have been corrupted the system
  262. will almost certainly crash.
  263. Warning: be very wary of using the machine
  264. after a program has crashed. Any memory
  265. corruption can cause serious problems either
  266. immediately or much later on. If you think the
  267. machine may be in a compromised state it is
  268. always much safer to reboot before continuing.
  269.  
  270.  
  271. MonAm Concepts
  272.  
  273. Here is a swift look at the concepts behind
  274. MonAm; it is a good idea to read this section
  275. before moving on to the next sections, even if
  276. you are an experienced programmer.
  277.  
  278.  
  279. Front Panel Display
  280.  
  281. When MonAm is invoked it displays a Front Panel
  282. showing registers, memory, source code and
  283. instructions. The name Front Panel stems from
  284. the type of panels that were mounted on
  285. mainframe and mini computers to provide
  286. information on the state of the machine at a
  287. particular moment, usually through the use of
  288. flashing lights. These lights represent whether
  289. or not particular flip-flops (electronic
  290. switches) within the computer are open or
  291. closed; the flip-flops that are chosen to be
  292. shown on this panel are normally those that
  293. make up the internal registers and flags of the
  294. computer thus enabling programmers and
  295. engineers to observe what the computer is doing
  296. when running a program.
  297. These were hardware front panel displays; what
  298. MonAm provides you with is a software front
  299. panel - the code within MonAm works out the
  300. state of the computer and then displays this
  301. information on the screen.
  302. The MonAm display consists of a number of
  303. windows through which you can view the 680x0
  304. registers, a disassembly of your program, your
  305. program´s source code or a portion of memory -
  306. you choose what you want in each window (within
  307. certain limitations). The layout of MonAm´s
  308. front panel is shown on the next page.
  309.                        
  310.                        
  311.  
  312.  
  313. MonAm´s Windows
  314.  
  315. As we have said, there are four different types
  316. of view through a window:
  317.  
  318. ·  a register window in which you can see the
  319.    various  680x0  data and address  registers,
  320.    the   program  counter  (PC),   the   status
  321.    register  (SR) and the current  instruction.
  322.    The   values   of  the  data   and   address
  323.    registers are shown in hexadecimal  together
  324.    with  some  information about the  locations
  325.    to which the registers point.
  326.  
  327. ·  a  disassembly window which shows a  680x0
  328.    disassembly  of  the  memory  that   it   is
  329.    addressing, including any symbols  that  are
  330.    found.
  331.  
  332. ·  a memory window which displays the contents
  333.    of   memory  locations  in  hexadecimal  and
  334.    ASCII.
  335.  
  336. ·  a  source  code window. In  this  type  of
  337.    window  you can view a text file  which  may
  338.    be  the source code of the program that  you
  339.    are  debugging, assuming that  this  exists.
  340.    You  can  display line numbers if  you  wish
  341.    and,  if  the program that owns  the  source
  342.    code  has  been compiled with line debugging
  343.    enabled,  you  will  be  able  to  use  this
  344.    information  to step through  the  program´s
  345.    source  code and set breakpoints  on  source
  346.    lines.
  347.  
  348. Up to five windows can be shown simultaneously
  349. or, by changing the width and height of the
  350. windows you, can show just two.
  351. Each window is numbered from 1 to 5 and can
  352. display different types of information - window
  353. 1 can be of any type, register, memory, source
  354. code or disassembly; windows 2 and 4 can be
  355. memory, disassembly or source code windows
  356. whilst windows 3 and 5 are restricted to being
  357. memory windows.
  358.  
  359.  
  360. Stacking Windows
  361.  
  362. Each window also has depth - you can stack
  363. views beneath a window so that you have almost
  364. limitless flexibility in what you choose to
  365. display.
  366. In addition you can split and widen most
  367. windows; split means to grow or to shrink the
  368. window vertically whilst widen means to do the
  369. same horizontally. These operations may hide
  370. other windows temporarily or they may uncover
  371. hidden windows.
  372.  
  373.  
  374. Locking Windows
  375.  
  376. Each window may also be locked to an arbitrary
  377. expression. Thus, you can lock a memory window
  378. to a register so that it displays the contents
  379. of the memory addressed by that register. Or
  380. you might want to lock a disassembly window to
  381. the PC, which is the default condition for
  382. window 2 unless you have saved.
  383. Each view on the window stack can be locked to
  384. a different expression although it does not
  385. make sense to lock the register window.
  386. All the above window features will be discussed
  387. in more detail later.
  388.  
  389.  
  390. The Current Window
  391.  
  392. MonAm uses the concept of a current window -
  393. this is denoted by displaying its title
  394. highlighted and is the window on which any
  395. operation will take place.
  396. The current window may be changed by pressing
  397. the Tab key to cycle between them, or by
  398. pressing the A key together with the window
  399. number, for example A2 selects window number 2,
  400. even if it is hidden currently.
  401.  
  402.         If your typing seems to be ignored
  403.         in MonAm don´t be alarmed; it
  404.         means that another screen is
  405.         active, such as that of your
  406.         program. To correct this click on
  407.         any part of the MonAm display. You
  408.         can always tell when the MonAm
  409.         display is active because the
  410.         mouse pointer will be bug-shaped.
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417. MonAm and Multi-Tasking
  418.  
  419. The Amiga¨ is a multi-tasking machine, and this
  420. imposes some restrictions on what MonAm can do.
  421. Having loaded a program (or task) into memory,
  422. that task is suspended. This means it is
  423. waiting, in this case for a MonAm command to
  424. let it continue.
  425. The other state the task can be in is executing
  426. - running at the same time as MonAm. Some
  427. commands require one or other of these states
  428. to operate - for example you can only single-
  429. step a task that is suspended. If the task is
  430. running you will get the error Task must be
  431. suspended! when you try to single-step it.
  432. MonAm can only debug one task at a time.
  433.  
  434.  
  435. Symbolic Debugging
  436.  
  437. A major feature of MonAm is its ability to use
  438. symbols taken from the original program whilst
  439. debugging. MonAm uses standard AmigaDOS file
  440. HUNK_SYMBOL hunks as produced by most Amiga¨
  441. programs that produce executable files, such as
  442. linkers, compilers and GenAm, the assembler
  443. supplied with Devpac Amiga. Naturally
  444. MaxonBASIC produces these.
  445. MonAm can also accept line number information
  446. from various different types of HUNK_DEBUG
  447. hunk, which enables the debugger to handle
  448. source code files that are connected with the
  449. program being debugged on a line basis. If the
  450. program to be debugged contains this line
  451. number information, you will be able to set
  452. breakpoints in its source code and even single-
  453. step it, source line by source line. Products
  454. that support this, currently, are: HighSpeed
  455. Pascal, Devpac Amiga 3, MaxonBASIC 2,
  456. MaxonBASIC 3 and SAS/Lattice C.
  457.  
  458.  
  459. MonAm Requesters
  460.  
  461. MonAm makes extensive use of requesters which
  462. are similar in concept to those in Intuition
  463. programs but have several differences.
  464.  
  465. A  MonAm requester displays the prompt  ESC  to
  466. abort  above  the top left corner  of  the  box
  467. together with a prompt, normally followed by  a
  468. blank line or some text to edit, with a cursor.
  469. At  any  time  a  requester may  be  exited  by
  470. pressing  Esc,  or data may be entered  at  the
  471. cursor  by normal typing. Various keys  may  be
  472. used to edit the text:
  473.  
  474.  
  475.  
  476.  
  477.  <-, ->      move  the  cursor  left  or
  478.              right through the text
  479.  Shift <-,   move  the  cursor  to   the
  480.  Shift ->    start  of  the line  or  to
  481.              the end of the line
  482.  Backspace   delete     the    character
  483.              behind the cursor
  484.  Del         delete the character  under
  485.              the cursor
  486.  AMIGA-X     delete the entire line
  487.  Esc         abandon the requester
  488.                        
  489.   commands available within MonAm requesters
  490.                        
  491. When you have finished entering a line, press
  492. the Return key; if the line contains errors the
  493. screen will flash and the Return key will be
  494. ignored allowing correction of the data before
  495. pressing Return again.
  496. Some MonAm requesters simply display a message
  497. together with the prompt Return; these are
  498. normally used to inform you of some form of
  499. error. The box will disappear on pressing the
  500. Return or Esc keys, whichever you find more
  501. convenient.
  502.  
  503.  
  504. Command Input
  505.  
  506. MonAm is controlled by single-key commands
  507. which gives a fast user-interface, although
  508. this can take getting used to if you are
  509. familiar with a line-oriented command interface
  510. of another debugger. Users of our debuggers on
  511. other machines such as the Atari range will
  512. find many commands are identical.
  513. In general the A key is the window key - when
  514. used in conjunction with other keys it acts on
  515. the current window. The Ctrl key is usually
  516. used to invoke commands connected with
  517. execution of the program that is being
  518. debugged.
  519. Commands may be entered in either upper or
  520. lower case. Those commands whose effects are
  521. potentially disastrous require the Ctrl key to
  522. be pressed in addition to a command key. The
  523. keys used were chosen to be easy to remember,
  524. wherever possible. Commands take effect
  525. immediately - there is no need to press Return
  526. and invalid commands are simply ignored. The
  527. relevant sections of the front panel display
  528. are updated after each command so any effects
  529. can be seen immediately.
  530. MonAm is a powerful and sometimes complex
  531. program and we realise that it is unlikely that
  532. many users will use every single command. For
  533. this reason the remainder of the MonAm manual
  534. is divided into two sections - the former is an
  535. introduction to the basic commands of the
  536. program, while the latter is a full reference
  537. section. It is possible for new users and
  538. beginners to use the debugger effectively while
  539. having only read the Overview; but don´t be
  540. intimidated by the Reference section.
  541.  
  542.  
  543. MonAm Overview
  544.  
  545.  
  546.  
  547. Starting MonAm
  548.  
  549. MonAm is invoked by typing the command
  550.  
  551.  
  552. monam [Return]
  553.  
  554.  
  555. or by calling it from the MaxonBASIC editor.
  556. If you start MonAm from a CLI you can include,
  557. optionally, a program name and a command line
  558. to be passed to the program. For example,
  559.  
  560.  
  561. monam c:mytest demos/finbonacci.s [Return]
  562.  
  563.  
  564. will cause MonAm to be invoked which will load
  565. a program called mytest and pass a filename to
  566. this program.
  567. If you started MonAm without asking for a
  568. program to be loaded, the prompt Executable
  569. file to load will appear. This gives you
  570. another chance to load a program to debug;
  571. either type the filename of the program that
  572. you want to investigate and hit Return or press
  573. Return by itself (or Esc) to quit the
  574. requester.
  575. Should MonAm have been called from the
  576. MaxonBASIC editor, the program that you are
  577. developing will be loaded automatically or used
  578. from memory, if it was compiled there.
  579.  
  580.  
  581. Debugging a Program
  582.  
  583. If you have asked MonAm to load a program to
  584. debug you may now be prompted for a command
  585. line, if you haven´t already given one; enter
  586. the line you want or just press Return. MonAm
  587. will then try to load the program. If it fails,
  588. it will display
  589.  
  590.  
  591. AmigaDOS error xx
  592.  
  593.  
  594. You can use the Load Program command to try to
  595. load the program again.
  596. Assuming the filename is valid, MonAm will load
  597. the executable file and any symbols within the
  598. file. After the file and its symbols have been
  599. loaded successfully, the message
  600.  
  601.  
  602. Breakpoint
  603.  
  604.  
  605. will appear; this is because MonAm places a
  606. breakpoint at the first instruction of the
  607. program and then executes it.
  608. The most common command in MonAm is probably
  609. single-step, obtained by pressing Ctrl-Z (or
  610. Ctrl-Y if you find it more convenient, perhaps
  611. because you have a German keyboard). This will
  612. execute the instruction at the PC, shown in the
  613. Register window and, normally, also in the
  614. Disassembly window. After executing it the
  615. debugger re-displays the values of the windows,
  616. so you can watch the processor execute your
  617. program, step by step. Single-stepping is the
  618. best way of going through sections of code that
  619. are suspect and require deeper investigation,
  620. but it is also the slowest - you may only be
  621. interested in a section of code near the end of
  622. your program which could take a long tome to
  623. reach if you have to single-step all the way.
  624. There is, of course, an answer.
  625.  
  626.  
  627. Breakpoints
  628.  
  629. A breakpoint is a special instruction placed
  630. into your program to stop it running and enter
  631. MonAm. There are many types of breakpoint but
  632. we will restrict ourselves to the simplest for
  633. now. A breakpoint may be set by pressing AB,
  634. then entering the address you wish to place the
  635. breakpoint. You can enter addresses in MonAm in
  636. hex (the default base), as a symbol, or as a
  637. complex expression. Examples of valid addresses
  638. are 1A2B0, prog_start, 10+mydata or #12 (this
  639. means line 12 hexadecimal). If you type in an
  640. invalid address the screen will flash and allow
  641. you to correct the expression.
  642. Having set a breakpoint you need some way of
  643. letting your program actually run, and Ctrl-R
  644. will do this. If will execute your program
  645. using the values of the registers displayed and
  646. starting from the PC. MonAm will be re-entered
  647. if a breakpoint has been hit, or if an
  648. exception occurs.
  649. MonAm uses its own screen which is independent
  650. of your program´s screen. If you use the screen
  651. gadgets at the top right of the MonAm screen
  652. you will see your current program´s display.
  653. This allows you to debug programs without
  654. disturbing their output. The MonAm screen will
  655. go to the back when you run a program from
  656. within the debugger and pop to the front when a
  657. breakpoint or other exception is reached. As
  658. usual, you can drag the MonAm screen from the
  659. top to reveal your program´s screen.
  660.  
  661.  
  662. Windows
  663.  
  664. MonAm uses its own windows too, and any window
  665. may be zoomed to the full screen size by
  666. pressing AZ. To return to the main display
  667. press AZ again, or the Esc key. The Esc key is
  668. also the best way of getting out of anything
  669. you may have invoked by accident. The Zoom
  670. command, like all A commands, works on the
  671. current window which you can change by pressing
  672. Tab. You can dump the current window to your
  673. printer by pressing AP.
  674. To change the address from which a window
  675. displays its data, press AA, then enter the new
  676. address. The locking of a window to an
  677. expression is detailed in the Reference
  678. section.
  679.  
  680.  
  681. Quitting MonAm
  682.  
  683. To quit MonAm press Ctrl-C. This returns MonAm
  684. directly to the CLI. If the task you are
  685. debugging is still running or suspended when
  686. you try and quit, you will be warned. If MonAm
  687. terminates while the task under investigation
  688. is running, the machine will crash if any
  689. exception occurs subsequently. A safer way to
  690. exit is to use the Ctrl-Q command to stop the
  691. task first. If you used the Debug option from
  692. the editor then Ctrl-C will always terminate
  693. your program as well as MonAm.
  694. We hope this overview has given you a good idea
  695. of the most common features of MonAm to let you
  696. get on with the complex process of writing and
  697. debugging assembly language programs. When you
  698. feel more confident you should try and read the
  699. following Reference section, probably best
  700. taken, like all medicine, in small doses.
  701.  
  702.  
  703. MonAm Reference
  704.  
  705. This is the reference section to MonAm; it is a
  706. complete description of the features and
  707. commands of this powerful debugger.
  708.  
  709. .idebugger:operators
  710.  
  711.  
  712.  
  713.  
  714. Numeric Expressions
  715.  
  716. There are many occasions within MonAm when you
  717. will want to enter a numeric expression;
  718. perhaps to lock a window to an expression, to
  719. assign a value to a register or to set the
  720. start address of a window.
  721. For these cases, MonAm has a full expression
  722. evaluator, based on that in GenAm, our
  723. assembler, including operator precedence. The
  724. main difference between it and a BASIC
  725. expression evaluator is that the default base
  726. for numbers is hexadecimal. The BASIC operators
  727. like and which have symbolic names are replaced
  728. by symbols.
  729.  
  730. The  precedence table for MonAm´s operators  is
  731. given below:
  732.  
  733.  
  734.  
  735.  
  736.   Precedence Operator(s)
  737.   of
  738.   Operator
  739.   1          monadic minus (-) and  plus
  740.              (+),  source  operators  (#
  741.              and ?)
  742.   2          bitwise not (~)
  743.   3          shift  left (<<) and  shift
  744.              right (>>)
  745.   4          bitwise  And  (&),  Or  (!)
  746.              and Xor (^)
  747.   5          multiply  (*)  and   divide
  748.              (/)
  749.   6          addition      (+)       and
  750.              subtraction (-)
  751.   7          equality  (=),  less   than
  752.              (<),   greater  than   (>),
  753.              inequality  (<>  and   !=),
  754.              less  than or equals  (<=),
  755.              greater   than  or   equals
  756.              (>=)
  757.  
  758. The comparison operators are signed and return
  759. 0 if false or -1 ($FFFFFFFF) if true. The shift
  760. operators take the left hand operand and shift
  761. it the number of bits specified in the right
  762. hand operand, vacated bits are filled with
  763. zeroes.
  764. This precedence can be overridden by the use of
  765. parentheses ( and ). With operators of equal
  766. precedence, expressions are evaluated from left-
  767. to-right. Spaces in expressions (other than
  768. those within quotes - ASCII constants) are not
  769. allowed.
  770. All expression evaluation is done using 32-bit
  771. signed-integer arithmetic, with no checking of
  772. overflow.
  773.  
  774.  
  775. Numbers
  776.  
  777.  
  778.  
  779. Absolute numbers may be in various forms:
  780.  
  781.     decimal constants, e.g. \1029
  782.     hexadecimal constants, e.g. 12f or $12f
  783.     octal constants, e.g. @730
  784.     binary constants, e.g. %1100010
  785.     character constants, e.g. ´X´
  786.  
  787. \ is used to denote decimal numbers, $ is used
  788. to denote hexadecimal numbers (the default), %
  789. for binary numbers, @ for octal numbers and
  790. single ´ or double " quotes for character
  791. constants.
  792.  
  793.  
  794. Character Constants
  795.  
  796.  
  797. Whichever quote is used to mark the start of  a
  798. string must also be used to denote its end  and
  799. quotes   themselves  may  be  used  in  strings
  800. delimited  with  the  same quote  character  by
  801. having it occur twice. Character constants  can
  802. be up to 4 characters in length and evaluate to
  803. right-justified  longs  with  null-padding   if
  804. required.  For example, here are some character
  805. constants and their ASCII and hex values:
  806.  
  807.  
  808.  
  809.  
  810.    Entered  Value     Hexadecimal
  811.    "Q"      Q         $00000051
  812.    ´hi´     hi        $00006869
  813.    "Test"   test      $54657374
  814.    "it´s"   it´s      $6974277C
  815.    ´it´´s´  it´s      $6974277C
  816.  
  817.  
  818.  
  819.  
  820.  
  821. Symbols may be referred to and are normally
  822. case-insensitive and significant to 32
  823. characters although this can be changed with
  824. the MonAm Preferences command.
  825. Registers may be referred to simply by name,
  826. such as A3 or d7 (case insensitive), but this
  827. causes a clash with certain hex numbers. To
  828. obtain such hex numbers precede them with
  829. either a leading zero or a $ sign.
  830. There are several reserved symbols which are
  831. case insensitive, namely CODE, SP, SR, and SSP.
  832. Both A7 and SP refer to either the user- or
  833. supervisor-stack, depending on the current
  834. value of the status register. CODE refers to
  835. the first hunk in the program. This is the same
  836. as HUNK1. The second hunk is HUNK2 and so on.
  837.  
  838.  
  839. Source Operators
  840.  
  841. .debuger:line numbers
  842. There are two operators which allow debugging
  843. at a source code level; these are the # and ?
  844. operators.
  845. To use these operators, you must have a source
  846. window open which is associated with the loaded
  847. executable program.
  848. In turn, this loaded program must have been
  849. produced by a package that includes line number
  850. information in the program´s HUNK.DEBUG hunk,
  851. i.e. you have used one of the Line Debug
  852. options (LINEDEBUG and HCLNDEBUG). Otherwise
  853. the # and ? operators are invalid.
  854. The # operator takes a source line number as
  855. its argument and returns the associated memory
  856. address, within the loaded program. So, say you
  857. have the source of hello.bas loaded into window
  858. 2 and the executable of hello loaded as the
  859. current program then:
  860.  
  861.  
  862. m3=#20
  863.  
  864.  
  865. will set the start address of window 3 to the
  866. address of line number 20 of the hello program
  867. (assuming that window 3 is not locked to
  868. another expression).
  869. If the line number is out of range of the
  870. source (e.g. if you ask for line number 100
  871. when there are only 90 lines of source), the
  872. result will be the address of the first or last
  873. line of the source, accordingly. If you use the
  874. # operator when there is no line number
  875. information available, the result will be 0.
  876. The ? operator is the reverse of #; it returns
  877. the source line number, given a memory address.
  878. If the address is out of range of the code
  879. connected with the source window, ? returns a
  880. value of 0.
  881. If you have only one source file loaded, the
  882. use of these operators is unambiguous. However,
  883. if you have loaded two or more source files
  884. into MonAm´s windows, # and ? may return
  885. unpredictable results; in this case it is best
  886. to use them when one source file is open in the
  887. current window - they will then relate to this
  888. file.
  889. These operators allow you to perform a variety
  890. of commands on a source level such as: Set
  891. Breakpoint, Run Until and Lock Window. This can
  892. make the process of debugging a complex program
  893. a far simpler and less tiresome task.
  894.  
  895.  
  896. Indirection
  897.  
  898. The MonAm expression evaluator also supports
  899. indirection using the { and } symbols.
  900. Indirection may be performed on a byte, word or
  901. long basis, by following the } with a period
  902. then the required size, which defaults to long.
  903. If the pointer is invalid, either because the
  904. memory is unreadable or even (if word or
  905. longword indirection is used) then the
  906. expression will not be valid.
  907. For example, the expression
  908.  
  909.  
  910.  {data_start+10}.w
  911.  
  912.  
  913. will return the word contents of location
  914. data_start+10, assuming data_start is even.
  915. Indirection may be nested as you would nest
  916. ordinary parentheses.
  917.  
  918.  
  919.  
  920.  
  921. Memory Registers
  922.  
  923. In addition there are 10 memories numbered M0
  924. through M9, which are treated in a similar way
  925. to registers and can be assigned to using the
  926. Register Set command. These are available for
  927. your own use although some have special
  928. functions as described below - you can view the
  929. memory registers by zooming the register
  930. window.
  931.  
  932. The  values  of memories 1 through 5  inclusive
  933. are  the  current start address of the relevant
  934. window  (including  source code  displays)  and
  935. assigning to them will change the start address
  936. of the display within that window.
  937.  
  938.  
  939. Here´s a full table of the memory registers:
  940.  
  941.  
  942.  
  943.  
  944.     Memory  Contents
  945.     Regist
  946.     er
  947.     m0      the    effective   address
  948.             referenced by the  current
  949.             instruction   (destination
  950.             where there are two)
  951.     m1      the   start   address   of
  952.             window 1
  953.     m2      the   start   address   of
  954.             window 2
  955.     m3      the   start   address   of
  956.             window 3
  957.     m4      the   start   address   of
  958.             window 4
  959.     m5      the   start   address   of
  960.             window 5
  961.     m6      spare
  962.     m7      spare
  963.     m8      the  start address of  any
  964.             binary file that has  been
  965.             loaded
  966.     m9      the  end  address  of  any
  967.             binary file that has  been
  968.             loaded
  969.  
  970. m8 and m9 are useful if you have loaded a
  971. binary file and then want to save it out to
  972. disk again - you do not have to remember the
  973. start and end addresses of the file, just use
  974. m8 and m9 when saving.
  975. If window 1 has a register display in it, m1
  976. will be meaningless but will retain any
  977. previous value.
  978.  
  979.  
  980.  
  981.  
  982. Window Types
  983.  
  984. There are five possible windows within the
  985. MonAm display and the exact contents of these
  986. windows and how they are displayed is detailed
  987. below. The allowed types of each window are:.
  988.  
  989.  
  990.  
  991.     Window  Allowed Type(s)
  992.     1       register,         memory,
  993.             disassembly, source
  994.     2       memory,      disassembly,
  995.             source
  996.     3       memory only
  997.     4       memory,      disassembly,
  998.             source
  999.     5       memory only
  1000.  
  1001. A window can have a number of different views
  1002. attached to it; you can think of the window as
  1003. a stack, having depth.
  1004. So, in window 2, you can view a disassembly of
  1005. code, a section of memory and a portion of an
  1006. ASCII file, although only one of these at a
  1007. time is visible. To cycle through the different
  1008. views use the Next/Previous View commands and
  1009. to create or delete a display use the Open View
  1010. and Close View commands.
  1011. Most windows can also be split, either
  1012. vertically or horizontally so that more, or
  1013. less, can be displayed within the window - this
  1014. action may hide or reveal other windows and it
  1015. is best to experiment with the split commands
  1016. (described below) to understand how they work.
  1017. A window can be locked to an expression so that
  1018. its start address is dependent on the value of
  1019. that expression - see the Lock to Expression
  1020. command below.
  1021. You can also zoom a window; it will then occupy
  1022. the whole of MonAm´s screen.
  1023. Each type of window will now be described.
  1024.  
  1025.  
  1026. Register Window
  1027.  
  1028.  
  1029.  
  1030. The data registers are shown in hex, together
  1031. with the ASCII display of their four bytes. The
  1032. address registers are also shown in hex,
  1033. together with a hex display of the memory that
  1034. each register is addressing. This is word-
  1035. aligned or byte-aligned as necessary, with non-
  1036. readable memory displayed as **. To the right
  1037. of this hex display is its ASCII
  1038. interpretation.
  1039. The status register is shown in hex and in flag
  1040. form, additionally with U or S denoting user-
  1041. or supervisor-modes.
  1042. The PC value is shown together with a
  1043. disassembly of the current instruction. Where
  1044. this involves one or more effective addresses
  1045. these are shown in hex, together with a
  1046. suitably-sized display of the memory they point
  1047. to.
  1048. For example, the display
  1049.  
  1050.  
  1051.  TST.L $12A(A3) ;00001FAE 0F01
  1052.  
  1053.  
  1054. signifies that the value of $12A plus register
  1055. A3 is $1FAE, and that the word memory pointed
  1056. to by this is $0F01. A more complex example is
  1057. the display
  1058.  
  1059.  
  1060.  MOVE.W $12A(A3),-(SP) ;00001FAE 0F01 >
  1061. 0002AC08 FFFF
  1062.  
  1063.  
  1064. The source addressing mode is as before but the
  1065. destination address is $2AC08, presently
  1066. containing $FFFF. Note that this display is
  1067. always of a suitable size (MOVEM data being
  1068. displayed as a quad-word) and when pre-
  1069. decrement addressing is used this is included
  1070. in the address calculations.
  1071.  
  1072.  
  1073. Disassembly Window
  1074.  
  1075.  
  1076.  
  1077. Disassembly displays show memory as
  1078. disassembled instructions to the standard
  1079. described below. On the left the hex address is
  1080. shown, followed by any symbol, then the
  1081. disassembly itself. The current value of the PC
  1082. is denoted with a >, if it is visible.
  1083. You can scroll through the disassembly window
  1084. as described under Cursor Keys below.
  1085. If the instruction has a breakpoint placed on
  1086. it this is shown using square brackets ([ ])
  1087. afterwards, the contents of which depend on the
  1088. type of breakpoint.
  1089. For stop breakpoints this will be the number of
  1090. times left for this instruction to execute, for
  1091. conditional breakpoints it will be a ? followed
  1092. by the beginning of the conditional expression,
  1093. for count breakpoints it is an = sign followed
  1094. by the current count and for permanent
  1095. breakpoints a * is displayed.
  1096. The exact format of the disassembled op-codes
  1097. is to the Motorola standard. All output is
  1098. upper-case (except lower-case labels) and all
  1099. numeric output is in hexadecimal, except Trap
  1100. numbers. Leading zeroes are suppressed and the
  1101. $ hex delimiter is not shown on numbers less
  1102. than 10. Where relevant numerics are shown
  1103. signed.
  1104. The only deviation from Motorola standard is
  1105. the register lists shown in MOVEM instructions
  1106. - in order to save display space the type of
  1107. the second register in a range is abbreviated,
  1108. for example
  1109.  
  1110.  
  1111.  MOVEM.L d0-d3/a0-a2,-(sp)
  1112.  
  1113.  
  1114. will be disassembled as
  1115.  
  1116.  
  1117.  MOVEM.L d0-3/a0-2,-(sp)
  1118.  
  1119.  
  1120. Certain library calls will be shown
  1121. symbolically even if no symbol information was
  1122. loaded with your program. The disassembler is
  1123. intelligent and recognises a MOVE into register
  1124. A6 followed by a JSR using A6 so that the call,
  1125. if valid, will be displayed by name; for
  1126. example
  1127.  
  1128.  
  1129.  move.l 4,A6
  1130.  jsr    _LVOOpenLibrary(A6)
  1131.  
  1132.  
  1133. The disassembler does this for the exec,
  1134. graphics, dos and intuition libraries, using
  1135. the special file monam.libfile. If this file is
  1136. not found in the current directory or the
  1137. current libs: assignment during MonAm´s
  1138. initialisation then such disassembly will not
  1139. occur.
  1140.  
  1141.  
  1142. Memory Window
  1143.  
  1144.  
  1145.  
  1146. Memory displays show memory in the form of a
  1147. hex address, word-formatted hex display and
  1148. ASCII. Unreadable memory locations are denoted
  1149. by **. The number of bytes shown is calculated
  1150. from the window width, up to a maximum of 16
  1151. bytes per line. You can scroll through the
  1152. memory window as described under Cursor Keys
  1153. below.
  1154.  
  1155.  
  1156. Source Window
  1157.  
  1158.  
  1159.  
  1160. The source window shows ASCII files in a
  1161. similar way to a screen editor with the name of
  1162. the file displayed in the title bar. The
  1163. default tab setting is 8 though this can be
  1164. toggled to 4 with the Edit Window command.
  1165. You can choose whether or not to display line
  1166. numbers for the file and whether they are shown
  1167. in decimal or hexadecimal. When line number
  1168. information exists in the HUNK_DEBUG hunk of
  1169. your program, you can use the medium level
  1170. debugging features of MonAm to step through the
  1171. source and set breakpoints within it, rather
  1172. like you can with a source code debugger.
  1173. You can scroll through the source window as
  1174. described under Cursor Keys below.
  1175.  
  1176.  
  1177.  
  1178.  
  1179. Cursor Keys
  1180.  
  1181. The cursor keys can be used on the current
  1182. window, the action of which depends on the
  1183. display type.
  1184. On a memory display all four cursor keys change
  1185. the current address, by byte or line, while
  1186. Shift-Up and Shift-Down move a page in either
  1187. direction. On a disassembly display Up and Down
  1188. change the start address on an instruction
  1189. basis, Left and Right change the address on a word
  1190. basis and Shift Up and Shift Down on a page basis.
  1191. On a source-code display Up and Down change the
  1192. display on a line basis, and Shift Up and Shift
  1193. Down on a page basis.
  1194.  
  1195.  
  1196.  
  1197.  
  1198. Window Commands
  1199.  
  1200. Commands that are reached through the use of
  1201. the A (right Amiga) key are normally available
  1202. at any time. Many of these commands are
  1203. connected with and apply to the current window.
  1204. The current window is denoted by having an
  1205. inverse title and it can be changed by pressing
  1206. Tab or A plus the window number.
  1207. Most window commands work in any window, zoomed
  1208. or not, though when it does not make sense to
  1209. do something the command is ignored.
  1210. The exceptions to the above are the Stack,
  1211. Unstack and View Stack commands which, for ease
  1212. of use, are not reached through the A key and
  1213. do not work on a zoomed window.
  1214.  
  1215.  
  1216. AA or M                           Set Address
  1217. Allows you to set the starting address of a
  1218. memory, disassembly or source window (the
  1219. latter only if line number information exists
  1220. in the HUNK_DEBUG hunk). You can use any valid
  1221. expression to generate this start address e.g.
  1222.  
  1223.  
  1224. _main
  1225. $C227B8
  1226. StartProgram+8
  1227. PC
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233. AE                                  Edit View
  1234. On a memory window this lets you edit memory in
  1235. hexadecimal or ASCII. Hex editing can be
  1236. accomplished using keys 1-9, A-F, together with
  1237. the cursor keys. Pressing Tab switches between
  1238. hex & ASCII, ASCII editing takes each keypress
  1239. and writes it to memory. The cursor keys can be
  1240. used to move about memory. To leave edit mode
  1241. press the Esc key.
  1242. On a register display using this command is the
  1243. same as using AR, Register Set, described
  1244. shortly. Within a source window this command
  1245. toggles the tab setting between 4 and 8.
  1246. You cannot edit a disassembly window.
  1247.  
  1248. AG                           Goto Source Line
  1249. This command works on source windows and allows
  1250. you to choose the line that will appear at the
  1251. top of the window. If you select a line that is
  1252. beyond the end of the file, the last line will
  1253. be shown at the top of the window.
  1254.  
  1255.  
  1256.  
  1257. AL                         Lock to Expression
  1258. This allows source (with line number
  1259. information), disassembly and memory windows to
  1260. be locked to a particular expression. After any
  1261. exception the start address of the display is
  1262. re-calculated, depending on the locked
  1263. expression. Each stacked view within a window
  1264. can have its own lock.
  1265. MonAm will ignore you if you try to lock a
  1266. source window that refers to a program that
  1267. does not have line number information attached
  1268. to it.
  1269. If you try to lock a source window to an
  1270. expression that lies outside the address range
  1271. of the source file you will be ignored. This,
  1272. in fact, is very useful; it means that if you
  1273. have a stack of source windows (see below for
  1274. details of stacking windows) which make up the
  1275. executable that you are debugging and you lock
  1276. each display to the PC, you will be able to
  1277. trace the path of the program through each
  1278. source file.
  1279. If an instruction in the top view calls a
  1280. subroutine in the stack, the top view will not
  1281. change but, if you then view the relevant
  1282. stacked view, it will change to show you the
  1283. called subroutine.
  1284. To unlock, simply enter a blank string.
  1285. You can lock one window to another window by
  1286. using the memory registers such as M2. You can
  1287. even lock a window to the indirection of its
  1288. own memory register (e.g. {m2}) which might be
  1289. useful to step through a linked list (in
  1290. conjunction with the Esc key to update the
  1291. window each time).
  1292.  
  1293.  
  1294.  
  1295. AP                               Print Window
  1296. Dumps the current window contents onto the
  1297. printer or to a file. This command can be
  1298. aborted by pressing Esc. You can choose the
  1299. printer device and the filename using the
  1300. Preferences command.
  1301.  
  1302.  
  1303.  
  1304. AS                               Split Window
  1305. Splits a window vertically i.e. makes it taller
  1306. or shorter depending on its current state; this
  1307. may hide or uncover another window. You would
  1308. normally use this to set up the display as you
  1309. like it and then save the set-up with the Save
  1310. Preferences command. It can be useful at any
  1311. time, though, if you would like to see more
  1312. information in a window or you need another
  1313. window.
  1314. This command has no effect on window 1.
  1315.  
  1316.  
  1317. AT                                       Type
  1318. This command works on windows 1, 2 and 4; it
  1319. changes the type of the display between
  1320. register (for window 1), disassembly, memory
  1321. and source (if a source file has been loaded
  1322. into the window).
  1323.  
  1324. AW                               Widen Window
  1325. Splits a window horizontally i.e. makes it
  1326. wider or narrower depending on its current
  1327. state; this may hide or uncover another window.
  1328. You would normally use this to set up the
  1329. display as you like it and then save the set-up
  1330. with the Save Preferences command. It can be
  1331. useful at any time, though, if you would like
  1332. to see more information in a window or you need
  1333. another window.
  1334. This command has no effect on window 1.
  1335.  
  1336.  
  1337.  
  1338.  
  1339. AZ                                Zoom Window
  1340.  
  1341. This  zooms the current window to be full size.
  1342. Other A commands are still available and normal
  1343. size  can  be achieved by pressing  Esc  or  AZ
  1344. again.
  1345.  
  1346.   Zooming a register window shows some extra
  1347.   information (which depends on the processor
  1348.    type) and the memory registers (m0 - m9).
  1349.                        
  1350.         A zoomed window behaves
  1351.         differently from a normal window
  1352.         in that, as you scroll through it,
  1353.         it does not update the associated
  1354.         memory register (m1 to m5). Also,
  1355.         if you change the value of the
  1356.         memory register while in a zoomed
  1357.         window , the start address of the
  1358.         display will not change. Think of
  1359.         a zoomed window as only temporary.
  1360.                        
  1361.                        
  1362.                        
  1363.  Shift-.                             Open View
  1364.  Creates a new view on the current window and
  1365.   numbers it accordingly. The type of the new
  1366.  view will be the same as the previous one if
  1367.                this is possible.
  1368.   The display will be numbered xa, xb, xc, xd
  1369.  etc. where x is the number of the window e.g.
  1370. if you stack a new display on window 2, it will
  1371. be numbered 2b with the original display being
  1372.  numbered 2a. Remember, though, that there is
  1373.  only one memory register per window, but you
  1374.      can lock each display to a different
  1375.  expression. This gives a tremendous amount of
  1376.                  flexibility.
  1377. This command does not work on a zoomed window.
  1378. The associated memory register is bound to the
  1379. top view only, although all locks on all views
  1380.       are re-calculated where necessary.
  1381.                        
  1382.  Shift-,                            Close View
  1383.  Removes the visible display from the current
  1384. window´s display list, unless there is only one
  1385. display attached to this window, in which case
  1386.  the command does nothing. If you close a view
  1387. on a source window, the source file will be un-
  1388.   loaded from memory and a disassembly window
  1389.      will replace the closed source view.
  1390. All other displays attached to this window will
  1391. be re-numbered if necessary i.e. if you remove
  1392. display 2c from (2a, 2b, 2c, 2d), 2d will be re-
  1393.               numbered to be 2c.
  1394. This command does not work on a zoomed window.
  1395.                        
  1396.  . and ,                    Next/Previous View
  1397.  These two commands allow you to cycle through
  1398.   views that have been stacked onto a window.
  1399. Pressing . (full stop or period) cycles forward
  1400. through the available displays whilst , (comma)
  1401.   cycles backwards. Both will roll round in a
  1402.                      loop.
  1403. For example, say you have 3 displays stacked on
  1404.      window 4 (4a Source, 4b Memory and 4c
  1405.  Disassembly) and you are currently displaying
  1406.   4b Memory. Press . and 4c Disassembly will
  1407.    appear, press . again and you will see 4a
  1408.                     Source.
  1409. These commands do not work on a zoomed window.
  1410.                        
  1411.                       Esc
  1412.     Pressing Esc will update all the window
  1413.   displays, if necessary and re-calculate the
  1414.  addresses to which any windows and views are
  1415.                     locked.
  1416.   This can be very useful in many cases; for
  1417.  example say you have window 3 locked to {m5}
  1418.  (the address pointed to by window 5) and you
  1419.   then scroll through window 5. Normally this
  1420. will not update window 3. However, all you have
  1421.  to do is to press Esc when you want to update
  1422.      window 3 (and all the other windows).
  1423. You can press the Esc key while your program is
  1424.     running to see how the machine state is
  1425. changing (assuming that the MonAm screen is at
  1426.                   the front).
  1427.                        
  1428.  
  1429.                Other A Commands
  1430.  
  1431.  All A (right Amiga) commands (like the window
  1432. commands described above) are available for use
  1433.  at any time whilst you are using MonAm. There
  1434.   are a few other such commands that are not
  1435.         related to the current window:
  1436.                        
  1437.                        
  1438.                        
  1439.  AB                             Set Breakpoint
  1440.  Allows the setting of any type of breakpoint,
  1441.       described later under Breakpoints.
  1442.                        
  1443.  AO or O                      Show Other Bases
  1444. This prompts for an expression and displays its
  1445.  value in hexadecimal, decimal and as a symbol
  1446.                  if relevant.
  1447.                        
  1448.                        
  1449.  AR                               Register Set
  1450.  Allows any register to be set to a value, by
  1451. specifying the register, an equals sign and its
  1452. new value. It can also be used to set the value
  1453.  of the memory registers. For example the line
  1454.                        
  1455.                        
  1456.                     a3=a2+4
  1457.                        
  1458.                        
  1459.  
  1460. sets register A3 to be A2 plus 4 whereas:
  1461.  
  1462.  
  1463.  
  1464.  
  1465.  
  1466.  m3=m2
  1467.  
  1468.  
  1469. will set the value of the window 3 register to
  1470. be the same as the window 2 register. All
  1471. windows will then be re-drawn, which may cause
  1472. a display that you did not expect if, say, the
  1473. display in window 3 is locked to an expression.
  1474.  
  1475. You  can also use this to set the start address
  1476. of  a window when in zoom mode so that, on exit
  1477. from  zoom mode, the relevant window starts  at
  1478. the required address.
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485. Screen Switching
  1486.  
  1487. MonAm uses its own Screen display and will
  1488. always make itself the front and active window
  1489. whenever an exception (including breakpoints)
  1490. occurs.
  1491.  
  1492. V                           View other Screen
  1493. This will put the MonAm screen to the back,
  1494. normally showing your program´s screen.
  1495. Pressing any key will return the MonAm screen
  1496. (so long as you have not activated any other
  1497. window).
  1498.  
  1499.  
  1500.  
  1501. Breakpoints
  1502.  
  1503. Breakpoints allow you to stop the execution of
  1504. your program at specified points within it.
  1505. MonAm allows up to eight simultaneous
  1506. breakpoints, each of which may be one of five
  1507. types. When a breakpoint is hit MonAm is
  1508. entered and it then decides whether to halt
  1509. execution of your program (when it will enter
  1510. the front panel display) or continue; this
  1511. decision is based on the type of the breakpoint
  1512. and the state of your program´s variables.
  1513.  
  1514.  
  1515.  
  1516. Simple Breakpoint [1]
  1517.  
  1518. These are one-off breakpoints which, when
  1519. executed, are cleared and cause MonAm to be
  1520. entered.
  1521.  
  1522.  
  1523.  
  1524. Stop Breakpoint [n]
  1525.  
  1526. These are breakpoints that cause program
  1527. execution to stop after the break-pointed
  1528. instruction has been executed a specified
  1529. number of times. In fact a simple breakpoint is
  1530. really a stop breakpoint with a count of one.
  1531.  
  1532.  
  1533.  
  1534. Count Breakpoint [=]
  1535.  
  1536. Merely counters; each time such a breakpoint is
  1537. reached a counter associated with it is
  1538. incremented, and the program will resume. These
  1539. breakpoints are more like monitors - they never
  1540. cause a program to stop and are useful for
  1541. profiling.
  1542.  
  1543.  
  1544.  
  1545. Permanent Breakpoint [*]
  1546.  
  1547. These are similar to simple breakpoints except
  1548. that they are never cleared - every time
  1549. execution reaches a permanent breakpoint MonAm
  1550. will be entered.
  1551.  
  1552.  
  1553.  
  1554. Conditional Breakpoint [?]
  1555.  
  1556. The most powerful type of breakpoint; these
  1557. allow program execution to stop at a particular
  1558. address only if an arbitrarily complex set of
  1559. conditions apply. Each conditional breakpoint
  1560. has associated with it an expression
  1561. (conforming to the rules already described).
  1562. Every time the breakpoint is reached this
  1563. expression is evaluated, and if it is non-zero
  1564. (i.e. true) then the program will be stopped,
  1565. otherwise the program will continue.
  1566.  
  1567.  
  1568. AB                             Set Breakpoint
  1569. This is a window command allowing the setting
  1570. or clearing of breakpoints at any time. The
  1571. line entered should be one of the following
  1572. forms, depending on the type of breakpoint
  1573. required:
  1574.  
  1575.  
  1576. <address>
  1577.  
  1578.  
  1579. will set a simple breakpoint.
  1580.  
  1581.  
  1582. <address>,<expression>
  1583.  
  1584.  
  1585. will set a stop breakpoint at the given
  1586. address, which will execute <expression> times.
  1587. The expression is evaluated before the program
  1588. is executed.
  1589.  
  1590.  
  1591. <address>,=
  1592.  
  1593.  
  1594. will set a count breakpoint. The initial value
  1595. of the count will be zero.
  1596.  
  1597.  
  1598. <address>,*
  1599.  
  1600.  
  1601. will set a permanent breakpoint.
  1602.  
  1603.  
  1604. <address>,?<expression>
  1605.  
  1606.  
  1607. will set a conditional breakpoint, using the
  1608. given expression.
  1609.  
  1610.  
  1611. <address>,-
  1612.  
  1613.  
  1614. will clear any breakpoint at the given address.
  1615. Breakpoints cannot be set on addresses which
  1616. are odd, unreadable, or within ROM.
  1617. Every time a breakpoint is reached, regardless
  1618. of whether the program is interrupted or
  1619. resumed, the program state is remembered in the
  1620. History buffer, described below
  1621.  
  1622.  
  1623. Help                Show Help and Breakpoints
  1624. This displays the current breakpoints, task
  1625. status, its segment list (showing where your
  1626. program is), free memory and the system memory
  1627. list.
  1628. UK A500 1.2 users (who cannot use the Help key)
  1629. can also obtain this command by pressing AH.
  1630.  
  1631.  
  1632. Ctrl-B                      Simple Breakpoint
  1633. Included mainly for compatibility with MonAm 1,
  1634. this sets a simple breakpoint at the start
  1635. address of the current window, so long as it
  1636. contains a disassembly display. If a breakpoint
  1637. is already there then it will be cleared.
  1638.  
  1639. U                                   Run Until
  1640. This prompts for an address and a breakpoint
  1641. specifier (1, n, =, *, or ?). The chosen type
  1642. of breakpoint is then placed at the given
  1643. address and program execution resumed.
  1644.  
  1645.  
  1646.  
  1647. Ctrl-K                       Kill Breakpoints
  1648. Clears all set breakpoints. This is also done
  1649. automatically when you quit MonAm with a task
  1650. still running.
  1651.  
  1652. Ctrl-A                       Breakpoint After
  1653. A command that places a simple breakpoint at
  1654. the instruction after the instruction at the PC
  1655. and resumes execution from the PC. This is
  1656. particularly useful for DBF-type loops if you
  1657. don´t want to go through the loop, but just
  1658. want to see the result after the loop is
  1659. finished.
  1660.  
  1661. Ctrl-X                         Stop executing
  1662. This is a command to stop your task while it is
  1663. executing. It does this by forcing the Trace
  1664. bit to be set, so you will get a Trace
  1665. exception. While this does work on some
  1666. systems, be very careful if you stop a task in
  1667. the middle of some AmigaDOS ROM routines,
  1668. particularly signal handling and message
  1669. passing.
  1670.  
  1671.         The above command accesses memory
  1672.         fields that are not guaranteed to
  1673.         remain the same for different
  1674.         versions of the Amiga¨ operating
  1675.         system.
  1676.         This command was Ctrl-S in MonAm
  1677.         version 1.
  1678.  
  1679.  
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686. History
  1687.  
  1688. MonAm has a history buffer in which the machine
  1689. status is remembered for later investigation.
  1690. The most common way of entering data into the
  1691. history buffer is when you single-step, but in
  1692. addition every breakpoint reached and every
  1693. exception caused enters the machine state into
  1694. the buffer. The various forms of the Run
  1695. command also cause entries to be made into this
  1696. buffer.
  1697.  
  1698.         The history buffer has room for
  1699.         five entries - when it fills the
  1700.         oldest entry is removed to make
  1701.         room for the newest entry.
  1702.  
  1703.  
  1704.  
  1705. H                         Show History Buffer
  1706. This opens a large window displaying the
  1707. contents of the history buffer. All register
  1708. values are shown including the PC as well as a
  1709. disassembly of the next instruction to be
  1710. executed.
  1711.  
  1712.         If a disassembly in the History
  1713.         display includes an instruction
  1714.         which has a breakpoint placed on
  1715.         it, the [ ]s will show the current
  1716.         values for that breakpoint, not
  1717.         the values at the time of the
  1718.         entry into the history buffer.
  1719.  
  1720.  
  1721.  
  1722.  
  1723.  
  1724.  
  1725. Quitting MonAm
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732. Ctrl-C or AQ                       Exit MonAm
  1733. This exits MonAm, returning control to whatever
  1734. task invoked MonAm. All breakpoints are killed
  1735. although, if the task you are debugging is
  1736. still running or suspended when you try and
  1737. quit, you will be warned. If MonAm terminates
  1738. while the task under investigation is running,
  1739. the machine will crash should any exception
  1740. occurs subsequently. Generally the best way to
  1741. terminate a program is to set its PC to the
  1742. label System and continue from there, first.
  1743. If the Debug option has been used from the
  1744. MaxonBASIC editor then MonAm will terminate
  1745. automatically when the program it is debugging
  1746. has terminated.
  1747.  
  1748. Ctrl-Q                         Quit a program
  1749. This is a way of forcing the task being
  1750. debugged to quit. This can be hazardous to use,
  1751. and should only be done as a last resort. If
  1752. your program is terminated in this way it will
  1753. not clean up, and thus not de-allocate any
  1754. memory it was using or close windows etc.
  1755.  
  1756.         The above command accesses memory
  1757.         fields that are not guaranteed to
  1758.         remain the same for different
  1759.         versions of the Amiga¨ operating
  1760.         system.
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767. Loading & Saving
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773. Ctrl-L                           Load Program
  1774. This will prompt for a filename and a command
  1775. line and will attempt to load the file ready
  1776. for execution. If MonAm has already loaded a
  1777. program it is not possible to load another
  1778. until the former has terminated.
  1779. The file to be loaded must be an executable
  1780. file. Use the Load Binary File command if you
  1781. wish to edit other file types.
  1782.  
  1783.         This command is not available if
  1784.         MonAm has been invoked using Debug
  1785.         from the editor.
  1786.  
  1787.  
  1788.  
  1789.  
  1790.  
  1791. B                            Load Binary File
  1792. This will prompt for a filename and an optional
  1793. load address (separated by a comma) and will
  1794. then load the file where specified. If no load
  1795. address is given then memory will be allocated
  1796. from the system. M8 will be set to the start
  1797. address of the loaded file and M9 to the end
  1798. address.
  1799.  
  1800.         This is a change from version 2 of
  1801.         MonAm, where M0 and M1 were set to
  1802.         the start and end addresses of the
  1803.         loaded file.
  1804.  
  1805.  
  1806.  
  1807.  
  1808.  
  1809. S                            Save Binary File
  1810. This will prompt for a filename, a start
  1811. address and an (inclusive) end address. To re-
  1812. save a file recently loaded with the Load
  1813. Binary File command
  1814.  
  1815.  
  1816. <filename>,M8,M9
  1817.  
  1818.  
  1819. may be specified, assuming of course that M0
  1820. and M1 have not been re-assigned.
  1821.  
  1822.  
  1823.  
  1824. A or AQ                       Load ASCII File
  1825. This powerful command allows an ASCII file,
  1826. normally of source code, to be loaded and
  1827. viewed within MonAm. This can be loaded into
  1828. window 2 or window 4. If the loaded program has
  1829. line number information relevant to this source
  1830. file, you will be able to use line number
  1831. operators on this display to step through the
  1832. source code, set breakpoints within it etc.
  1833. A new view on this window will be opened if the
  1834. window already contains an ASCII file,
  1835. otherwise the text will replace the current
  1836. window. You can unload a source window using
  1837. the Close View command.
  1838. The source window will be locked automatically
  1839. to the PC.
  1840. Memory for source code displays is taken from
  1841. the system so sufficient free memory must be
  1842. available.
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849. Executing Programs
  1850.  
  1851.  
  1852.  
  1853. Ctrl-R                Return to program / Run
  1854. This runs the current program with the given
  1855. register values at full speed and is the normal
  1856. way to resume execution after entry via a
  1857. breakpoint or an exception.
  1858.  
  1859.  
  1860.  
  1861. Ctrl-Z                            Single-Step
  1862. Single-steps the instruction at the PC with the
  1863. current register values. Single-stepping a
  1864. Trap, Line-A or Line-F opcode will, by default,
  1865. be treated as a single instruction.
  1866.  
  1867. Ctrl-Y                            Single-Step
  1868. Identical to Ctrl-Z above but included for the
  1869. convenience of users of German keyboards.
  1870.  
  1871.  
  1872.  
  1873. Ctrl-T                      Trace Instruction
  1874. This interprets the instruction at the PC using
  1875. the displayed register values. It is similar to
  1876. Ctrl-Z but obeys BSRs, JSRs, Traps, Line-A and
  1877. Line-F calls as if one instruction, re-entering
  1878. the debugger on return from them to save
  1879. stepping all the way through the routine or
  1880. trap. It works on instructions in ROM or RAM.
  1881.  
  1882.  
  1883.  
  1884. Ctrl-S                       Skip Instruction
  1885. Ctrl-S increments the PC register by the size
  1886. of the current instruction thus causing it to
  1887. be skipped. Use this instead of Ctrl-Z when you
  1888. know that this instruction is going to do
  1889. something it shouldn´t.
  1890.  
  1891.  
  1892.  
  1893. R                               Run (various)
  1894. This is a general Run command and prompts for
  1895. the type of execution, selected by pressing a
  1896. key.
  1897.  
  1898.  
  1899. Run G                                     Go
  1900. This is identical to Ctrl-R and resumes the
  1901. program at full speed.
  1902.  
  1903. Run I                            Instruction
  1904. This executes the entered number of
  1905. instructions remembering information in the
  1906. History buffer and then returning to MonAm.
  1907. Traps are treated as single-instructions.
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914. Searching Memory
  1915.  
  1916.  
  1917.  
  1918. G              search memory (Get a sequence)
  1919. You will see the prompt Search for B/W/L/T/I?,
  1920. standing for Bytes, Words, Longs, Text and
  1921. Instructions.
  1922. If you select B, W or L you will then be
  1923. prompted to enter the sequence of numbers you
  1924. wish to search for, each separated by commas.
  1925. MonAm is not fussy about word-alignment when
  1926. searching, so it can find longs on odd
  1927. boundaries, for example.
  1928. If you select T you may search for any given
  1929. text string, for which you will be prompted.
  1930. The search will be case-dependent or case-
  1931. independent, as you have chosen.
  1932. If you select I you can search for part or all
  1933. of the mnemonic of an instruction, for example
  1934. if you searched for $E78(A5) you would find an
  1935. instruction like MOVE.L D7,$E78(A5). The case
  1936. of the string you enter is un-important unless
  1937. you have chosen it to be so, but you should
  1938. bear in mind the format that the disassembler
  1939. produces, e.g. always use hex numbers, refer to
  1940. A7 rather than SP and so on.
  1941. Having selected the search type and parameters,
  1942. the search begins, control passing to the Next
  1943. command, described below.
  1944.  
  1945. Searching Source-Code Windows
  1946. If the G command is used on a source-code
  1947. window the T sub-command is automatically
  1948. chosen and if the text is found the window will
  1949. re-display the line containing it.
  1950.  
  1951. N                                   find Next
  1952. N can be used after the G command to find
  1953. subsequent occurrences of the search data. With
  1954. the B, W, L and T options you will always find
  1955. at least one occurrence, which will be in the
  1956. buffer within MonAm that is used for storing
  1957. the sequence. With the T option you may also
  1958. find a copy in the system keyboard buffer. With
  1959. these options, the Esc key is tested every 64k
  1960. bytes and can be used to stop the search. With
  1961. the I option, which is very much slower, the
  1962. Esc key is tested every 2 bytes.
  1963. The search will start just past the start
  1964. address of the current window (except register
  1965. windows) and if an occurrence is found re-
  1966. display the window at the given address.
  1967. The search area of memory goes from 0 to the
  1968. end of chip memory, then $F80000 to $FFFFFF
  1969. (the ROM) then any additional RAM.
  1970.  
  1971.  
  1972. Miscellaneous
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978. Ctrl-P                            Preferences
  1979. This permits control over various options
  1980. within MonAm. The first three require Y/N
  1981. answers, pressing Esc aborts or Return leaves
  1982. them alone.
  1983.  
  1984. Auto-load source file
  1985. When switched to Yes, upon loading a program,
  1986. MonAm will attempt to load the first source
  1987. file associated with the program. This will
  1988. only occur if the executable file contains line
  1989. number debugging information and the source
  1990. file can be found in the current directory. The
  1991. new source file window will then be locked to
  1992. the Program Counter in order to track program
  1993. flow. This is of most use when debugging a
  1994. program generated from a single source file.
  1995.  
  1996. Source window line numbers
  1997. Affects whether line numbers are shown for all
  1998. debugger source windows. You may select No line
  1999. numbers, Decimal numbers or Hex numbers.
  2000. Hexadecimal is often the preferred setting
  2001. because by default, MonAm treats all numbers as
  2002. hex. Decimal line numbers, used with the #
  2003. operator for example, require a prefix of
  2004. backslash.
  2005.  
  2006. Automatic ´_´ or ´@´ prefix
  2007. This is provided mainly for the convenience of
  2008. C compiler users. With it enabled, MonAm will
  2009. automatically add a leading underscore or @
  2010. character to the appropriate symbols. However,
  2011. symbols without the leading character will
  2012. still take precedence.
  2013.  
  2014. Case insensitive symbols
  2015. MonAm version 3 defaults to using case
  2016. insensitive symbols, i.e. upper and lower case
  2017. characters are not distinguished between.
  2018. Selecting No will mean that you must match the
  2019. case of each symbol character exactly as with
  2020. previous versions of MonAm.
  2021.  
  2022. Symbol significance
  2023. This prompts for the significant length of
  2024. symbols, which is normally 32 but may be
  2025. reduced to as low as 8 or increased if
  2026. required. Although reducing this can save some
  2027. typing, using too low a value can make some
  2028. symbols impossible to select.
  2029.  
  2030. Show relative offset symbols
  2031. This option defaults to Yes and affects the
  2032. disassembly of address register indirect with
  2033. offset addressing modes, i.e. xxx(An). With the
  2034. option on, the current value of the given
  2035. address register is added to the offset then
  2036. searched for in the symbol table. If found it
  2037. is disassembled as symbol(An). This option is
  2038. very useful for certain styles of assembly
  2039. language programming as well as high level
  2040. languages which use a base register as a major
  2041. offset, such as SAS/C which uses A4 as a
  2042. pointer to the merged data section.
  2043.  
  2044. Show ZAn in disassembly
  2045. Is normally switched off but advanced
  2046. programmers may wish to enable the display of
  2047. the normally hidden Z registers used by some
  2048. 680x0 instructions.
  2049.  
  2050. Interlace
  2051. Allows you to choose between a double height
  2052. interlaced NTSC/PAL screen for MonAm(Y), a non-
  2053. interlaced NTSC/PAL screen (N) or the default
  2054. screen mode set by the Workbench Screen Mode
  2055. preferences(D). This option will take effect
  2056. after preferences have been saved and MonAm
  2057. restarted. MonAm will normally replicate the
  2058. Workbench screen´s format.
  2059.  
  2060. Printer device name
  2061. This lets you set the device that MonAm uses
  2062. for its printer commands. The default is PRT:,
  2063. the system printer device configured through
  2064. Preferences. You may specify an AmigaDOS
  2065. filename in order to re-direct printing to
  2066. disk.
  2067.  
  2068. Save preferences
  2069. Reply Y to this command to save your current
  2070. preferences to the file MonAm.prefs in the
  2071. current directory. When MonAm loads it will
  2072. read your preferences from this file.
  2073. MonAm.prefs is firstly searched for in the
  2074. current directory, then in the ENV:Devpac
  2075. directory, in a similar way to the editor
  2076. preferences file. Note that the ENV:Devpac
  2077. directory is used rather than ENV:HBasic. This
  2078. is for the benefit of users of our Devpac
  2079. assembly language development system; there is
  2080. only one debugger preferences file and the
  2081. debugger from either package may be used
  2082. interchangeably. Note however that versions
  2083. 3.04 and below of MonAm did not ´understand´
  2084. about BASIC string constants.
  2085.  
  2086.  
  2087.  
  2088. I                            Intelligent Copy
  2089. This copies a block of memory to another area.
  2090. The addresses should be entered in the form
  2091.  
  2092.  <start>,<inclusive_end>,<destination>
  2093. The copy is intelligent in that the block of
  2094. memory may be copied to a location which
  2095. overlaps its previous location.
  2096.  
  2097.         No checks at all are made on the
  2098.         validity of the move; copying to
  2099.         non-existent areas of memory is
  2100.         likely to crash MonAm and
  2101.         corrupting system areas may well
  2102.         crash the machine.
  2103.  
  2104.  
  2105.  
  2106.  
  2107. L                                 List Labels
  2108. This opens up a large window and displays all
  2109. loaded symbols. Any key displays the next page,
  2110. pressing Esc aborts. The symbols will be
  2111. displayed in the order they were found on the
  2112. disk (or in memory if using the Debug option
  2113. from the editor).
  2114.  
  2115. Ctrl-U name                    Unload symbols
  2116. This command can only be used if you are
  2117. debugging a task which had a symbol table
  2118. loaded with it. What it does is de-allocate the
  2119. memory used for storing the symbols, freeing it
  2120. for the system to use. This can be very useful
  2121. if memory is tight while debugging a larger
  2122. program, as you can load it, together with
  2123. symbols, set a breakpoint at a symbolic
  2124. address, then lose the labels before letting it
  2125. run. Of course once you hit your breakpoint you
  2126. won´t have any symbols.
  2127.  
  2128.  
  2129. W                            Fill Memory With
  2130. This fills a section of memory with a
  2131. particular byte. The range should be entered in
  2132. the form
  2133.  
  2134.  <start>,<inclusive_end>,<fillbyte>
  2135. The warning described previously about no
  2136. checks applies equally to this command.
  2137.  
  2138.  
  2139. P                 Disassemble to Printer/Disk
  2140. This command allows the disassembly of an area
  2141. of memory to printer or disk, complete with
  2142. original labels and, optionally, an automatic
  2143. list of labels created by MonAm, based on cross-
  2144. references. The first line should be entered as
  2145.  
  2146.  
  2147.  <start_address>,<end_address>
  2148.  
  2149.  
  2150. The next line prompts for the area of memory
  2151. used to build the cross-reference list, which
  2152. should be left blank if no automatic labels are
  2153. required else should be of the form
  2154.  
  2155.  
  2156.  <buffer_start>,<buffer_end>
  2157.  
  2158.  
  2159. Next is the prompt for data areas which will be
  2160. disassembled as DC instructions, of the form
  2161.  
  2162.  
  2163.  <data_start>,<data_end>[,<size>]
  2164.  
  2165.  
  2166. The optional size field should be B, W or L,
  2167. defaulting to L, determining the size of the
  2168. data. When all data areas have been defined, a
  2169. blank line should be entered.
  2170. Finally a filename prompt will appear; if this
  2171. is blank all output will be to the printer,
  2172. else it will be assumed to be a disk file.
  2173. If automatic labels were specified there may be
  2174. a delay at this point while the table is
  2175. generated. Automatic labels are of the form
  2176. Lxxxxx where xxxxx is the actual hex address.
  2177.  
  2178. Printer Output
  2179. This is of the form of an 8 digit hex number,
  2180. then up to 10 words of hex data, 12 characters
  2181. of any symbol, then the disassembly itself.
  2182. Printer output may be aborted by pressing Esc.
  2183.  
  2184. Disk Output
  2185. This is in a form directly loadable by GenAm,
  2186. the assembler supplied with Devpac, consisting
  2187. of any symbol, a tab, then the disassembly
  2188. itself, with a tab separating any operand from
  2189. the op-code. If you are disassembling an area
  2190. of memory without loaded symbols then the XREF
  2191. option should be used else no symbols will
  2192. appear at all in the output file. Pressing Esc
  2193. or a disk error will abort the disassembly.
  2194.  
  2195. M                              Modify Address
  2196. Included for compatibility with MonAm 1,
  2197. equivalent to AA.
  2198.  
  2199. O                            Show Other Bases
  2200. Included for compatibility with MonAm 1,
  2201. equivalent to AO.
  2202.  
  2203.  
  2204. D                    Change Drive & Directory
  2205. This allows the current drive and sub-directory
  2206. to be changed.
  2207.  
  2208.  
  2209.  
  2210. Command Summary
  2211.  
  2212.  
  2213. Window Commands
  2214. AA            Set Address
  2215. AB            Set Breakpoint
  2216. AE            Edit View
  2217. AG            Goto Source Line
  2218. AL            Lock to Expression
  2219. AP            Print Window
  2220. AR            Register Set
  2221. AS            Split Window
  2222. AT            Change Type
  2223. AW            Widen Window
  2224. AZ            Zoom Window
  2225. Shift-.       Open View
  2226. Shift-,       Close View
  2227. . and ,       Next/Previous View
  2228. Esc           Update all Windows
  2229.  
  2230. Breakpoints
  2231. Ctrl-A        Breakpoint After
  2232. Ctrl-B        Simple Breakpoint
  2233. Ctrl-K        Kill Breakpoints
  2234. Ctrl-X        Stop Executing
  2235. AB            Set Breakpoint
  2236. U             Run Until
  2237. Help          Show Help and Breakpoints
  2238.  
  2239. Loading and Saving
  2240. Ctrl-L        Load Program
  2241. A             Load ASCII File
  2242. B             Load Binary File
  2243. S             Save Binary File
  2244.  
  2245. Executing Programs
  2246. Ctrl-R        Return to program / Run
  2247. Ctrl-S        Skip Instruction
  2248. Ctrl-T        Trace Instruction
  2249. Ctrl-Y        Single-Step
  2250. Ctrl-Z        Single-Step
  2251. R             Run (various)
  2252.  
  2253. Searching Memory
  2254. G             Search Memory (Get a sequence)
  2255. N             Find Next
  2256.  
  2257. Miscellaneous
  2258. Ctrl-C or AQ  Exit MonAm
  2259. Ctrl-Q        Quit a program
  2260. Ctrl-P        Preferences
  2261. Ctrl-U        Unload symbols
  2262. AO or O       Show Other Bases
  2263. D             Change Drive & Directory
  2264. H             Show History Buffer
  2265. I             Intelligent Copy
  2266. L             List Labels
  2267. M             Modify Address
  2268. P             Disassemble to Printer/Disk
  2269. V             View other Screen
  2270. W             Fill Memory With
  2271.  
  2272.  
  2273.  
  2274.  
  2275. Bug Hunting
  2276.  
  2277. There are probably as many strategies for
  2278. finding bugs as there are programmers; there is
  2279. really no substitute for learning the hard way,
  2280. by experience. However, here are some hints
  2281. which we have learnt, the hard way!
  2282. Firstly, a very good way of finding bugs is to
  2283. look at the source code and think. The
  2284. disadvantage of reaching first for the
  2285. debugger, then second for the source code, is
  2286. that it gets you into bad habits. You may
  2287. switch to a machine or programming environment
  2288. that does not offer low-level debugging, or at
  2289. least not one as powerful you are used to.
  2290. If a program fails in a very detectable way,
  2291. such as causing an exception, debugging is
  2292. normally easier than if, say, a program
  2293. sometimes doesn´t quite work exactly as it
  2294. should.
  2295. Many bugs are caused by a particular memory
  2296. location being stepped on. Where the offending
  2297. memory location is detectable, by producing a
  2298. bus error, for example, a conditional
  2299. breakpoint placed at one or more main
  2300. subroutines can help greatly. For example,
  2301. suppose the global variable at address $123456
  2302. is somehow becoming odd during execution, the
  2303. conditional expression could be set up as
  2304.  
  2305.  {$123456}&1
  2306. Count breakpoints are a good way of tracking
  2307. down bugs before they occur. For example,
  2308. suppose a particular subroutine is known to
  2309. eventually fail but you cannot see why, then
  2310. you should set a count breakpoint on it, then
  2311. let the program run. At the point where the
  2312. program stops, because of an exception say,
  2313. look at the value of the count breakpoint
  2314. (using Help). Terminate the program, re-load
  2315. it, then set a stop breakpoint on the
  2316. subroutine for that particular value or one
  2317. before it. Let it run, then you can follow
  2318. through the sub-routine on the very call that
  2319. is fails on, to try and work out why.
  2320. Good luck!
  2321.  
  2322.  
  2323. Exceptions
  2324.  
  2325. MonAm employs the 680x0 processor exceptions to
  2326. stop runaway programs and to single-step, so at
  2327. this point it would be useful to explain them
  2328. and detail what normally happens when they
  2329. occur on an Amiga.
  2330. While using the 680x0 processors, there are
  2331. various types of exception that can occur, some
  2332. deliberately, others accidentally. An exception
  2333. is a special condition that takes priority over
  2334. normal processing - it might be an interrupt
  2335. from an external device, an illegal
  2336. instruction, an address error, a co-processor
  2337. violation or a number of other pre-defined
  2338. events.
  2339. When an exception occurs the processor´s
  2340. context is saved on the supervisor stack and
  2341. execution is then transferred to any one of 256
  2342. different addresses, held in the exception
  2343. table (on the 68010 upwards, the address of the
  2344. start of this table is held in the vector base
  2345. register, or VBR). This table is set up by the
  2346. Amiga´s operating system so that an exception
  2347. effectively transfers control to Exec, which is
  2348. part of the Amiga´s operating system.
  2349. The operating system then looks to see if the
  2350. task that was running when the exception
  2351. occurred has installed an exception handler
  2352. i.e. the task wants to handle exceptions
  2353. itself. If it has, control is passed to that
  2354. exception handler; this is how MonAm traps
  2355. exceptions because MonAm has attached such an
  2356. exception table to the task that it has
  2357. executed.
  2358. Unfortunately, there a few exceptions that
  2359. MonAm cannot trap because Exec does not pass
  2360. them on - in these cases the operating system
  2361. does what it normally does in the absence of an
  2362. exception handler, it produces a Software Error
  2363. alert (the dreaded Guru).
  2364. MonAm actually uses two of the exception
  2365. vectors itself, one to set breakpoints in
  2366. programs and the other to allow single-
  2367. stepping.
  2368.  
  2369. The various forms of exceptions, their usual
  2370. results, and what happens when they occur with
  2371. MonAm active is shown in the following table,
  2372. which is a summary of the exception table. Note
  2373. that the first 64 vectors are defined by
  2374. Motorola.
  2375.  
  2376.  
  2377.  
  2378.