home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / d86v322.zip / D02.DOC < prev    next >
Text File  |  1988-05-20  |  13KB  |  236 lines

  1. CHAPTER 2   D86 DEMONSTRATION
  2.  
  3. To demonstrate some of the powers of D86, let's walk through a
  4. D86 session.
  5.  
  6. 1. Make sure your current directory contains all the files
  7.    A86.COM, D86.COM, and HEXOUT.8.
  8.  
  9. 2. Assemble the HEXOUT program by typing the command A86
  10.    HEXOUT.8.  The A86 assembler will create the files HEXOUT.COM
  11.    and HEXOUT.SYM.  Look over the listing of the program, to get
  12.    acquainted with what it does.
  13.  
  14. 3. Type the command D86 HEXOUT 41 42 5A followed by the ENTER
  15.    key. Everything following the "D86 " in the line you just
  16.    typed is what you would have typed if you had invoked HEXOUT
  17.    without the debugger-- 41 42 5A are the hex codes that HEXOUT
  18.    will turn into ABZ and send to the console. When the debugger
  19.    takes control, the screen should blank; and the D86 debugger
  20.    screen should appear.  The blinking cursor should be at the
  21.    bottom left.  A sign-on message should appear at the upper
  22.    right.  A disassembly of the HEXOUT program should be in the
  23.    upper left. The label HEXOUT should appear on the first line,
  24.    followed on the second line by the address 0100 and the
  25.    instruction MOV  SI,TAIL_BUFF.  To the left of the address
  26.    should be a reverse video hash sign.  If you have a CGA
  27.    monitor, the hash sign will blink, to compensate for the fact
  28.    that the reverse video isn't as obvious in the lower
  29.    resolution of CGA.
  30.  
  31. 4. Notice the display of register values in the lower left
  32.    corner. The values are all 4-digit hexadecimal.  At the top of
  33.    the second column of registers is a sequence of lower case
  34.    letters. This is the flags display.  Each small letter stands
  35.    for a flag whose value is currently TRUE.  The flags settings
  36.    are those that were handed to D86 by the operating system
  37.    starting the program; for MSDOS V3.1, the settings are "i z
  38.    e".  That display indicates that the interrupt flag "i", the
  39.    zero flag "z", and the parity-even flag "e" are all TRUE; the
  40.    other flags are FALSE. To the right of the registers are six
  41.    lines labelled 1: through 6:.  These are the memory window
  42.    lines. Since you haven't specified any memory windows yet,
  43.    they contain nothing but their numbers.  Below the memory
  44.    window lines is a line labelled 0:.  This is the stack display
  45.    line. The number 0: gives the number of words on the stack,
  46.    currently zero because nothing has been pushed onto the stack.
  47.  
  48. 5. Observe that the sign-on message tells you to press Alt-F10
  49.    for help.  Do so (that is, hold down the Alt key while
  50.    pressing the F10 key).  You are now in help mode, where you
  51.    will remain until you press Alt-F10 again.  D86 will keep
  52.    changing the help window, depending on what it thinks you are
  53.    doing. Right now you have a summary of the main function keys,
  54.    plus a few other things.  Press F10 (without the Alt), and
  55.    you'll get a summary of one-letter debugger commands.  Press
  56.    F10 a second time and you'll get a summary of Ctrl-key
  57.    commands.  Finally, press F10 a third time to return to the
  58.    function-key help screen.
  59.                                                               2-2
  60.  
  61. 6. Let's try an immediate assembly language instruction. Press
  62.    the "M" key, which is the first letter of the immediate
  63.    instruction MOV AX,123.  Note that the reverse video block
  64.    jumps from the hash sign within the disassembly, down to the
  65.    line just above the blinking cursor.  The block is the
  66.    debugger's cursor; the blinking cursor is the program's
  67.    console output cursor.  The debugger does not use the blinking
  68.    cursor because we do not want the program's output to
  69.    interfere with the debugger's output.  Also note that the help
  70.    window is now telling you that you are typing in an assembly
  71.    language line.
  72.  
  73. 7. Complete the line MOV AX,123 followed by the ENTER key (from
  74.    now on I'll assume that you know that lines are followed by
  75.    the ENTER key, and that any periods at the end of a line are
  76.    part of my sentence, and not part of what you type).  The
  77.    debugger immediately executes the assembly language line you
  78.    just typed, setting the register AX.  Note that you did not
  79.    have to learn a debugger command for setting registers; if you
  80.    know A86, you already know how to set registers!  The value of
  81.    AX is now 007B, which may surprise you if you expected 0123.
  82.    A86's default base is 10, so 123 was taken as decimal; which
  83.    is hex 7B.  Type MOV AX,0123 instead, to get a value of hex
  84.    123.
  85.  
  86. 8. Let's now play with the flags display.  Type the line ADD
  87.    AL,05D, which changes AL (the last two digits of AX) to hex
  88.    80, and alters the flags to "o is a ".  The interrupt flag is
  89.    still on; but zero and parity-even are now off.  They have
  90.    been replaced by "o" overflow, "s" sign, and "a" auxiliary
  91.    carry.
  92.  
  93. 9. Type the line consisting of just CMC.  This is the Complement
  94.    Carry instruction.  Observe that the "c" appears.  Notice also
  95.    that the CMC that you typed remains on the screen.  Notice on
  96.    the help window the entry "F3 RepeatCmd".  This tells you that
  97.    the F3 key will repeat the last line command (not function
  98.    key) that you typed.  Press F3 several times, to see the carry
  99.    flag toggle on and off.  Isn't that the cleanest flags display
  100.    you've ever seen?
  101.  
  102. 10. Let's single step an instruction.  Press the F1 key.  This
  103.     executes the program instruction, loading the SI register
  104.     with TAIL_BUFF.  The disassembly cursor moves down to the
  105.     next instruction.  Observe that SI has changed to 0081, which
  106.     is the pointer to the invocation command tail, which should
  107.     contain the string typed after HEXOUT: " 41 42 5A" followed
  108.     by a carriage return code (hex 0D).
  109.                                                               2-3
  110.  
  111. 11. Let's examine memory to verify that last assertion.  Press
  112.     the "1" key. The cursor jumps to the start of memory window
  113.     1, and the help window gives you a huge choice of memory
  114.     types to display.  The entry "ByteHex 2" tells us that "B"
  115.     will cause hex bytes to be displayed.  The "2" indicates that
  116.     the display occupies a fixed number of display bytes for
  117.     every memory unit, namely 2 hex digits.  Type B followed by a
  118.     comma, to indicate that you want nothing but hex bytes to be
  119.     displayed. Now the help window asks for a segment location.
  120.     Let's use the DS register: type DS followed by a comma. Now
  121.     the help window wants an offset within the segment: type SI.
  122.     Before typing the terminating ENTER, backspace out what you
  123.     have typed, and watch the help windows regress appropriately.
  124.     Isn't that impressive?  Now retype the line, "B,DS,SI".  Note
  125.     that when you press ENTER, the line fills out with hex
  126.     values: 20 34 31 20 34 32 20 35 41 0D etc.  (61 instead of 41
  127.     is OK; it means you typed the invocation in lower case.)
  128.  
  129. 12. Let's look at the same line, displayed as text.  Type "2",
  130.     moving to memory line 2, then type the line "T,SI".  This
  131.     time you specified type T for text, and you left out the
  132.     segment register specification.  D86 uses DS when you leave
  133.     out the segment register; so in this case you'll get the same
  134.     segment. This time the display starts with "41 42 5AM"; the
  135.     "M" is the carriage return, which is control-M, ambiguously
  136.     displayed. You can read Chapter 6 later on for descriptions
  137.     of all the types, including other text types allowing
  138.     non-ambiguous displays.
  139.  
  140. 13. Let's execute the next instruction, CALL GET_HEX.  Here we
  141.     have a choice, between executing the procedure all at once,
  142.     or stepping into the procedure to execute its instructions
  143.     one at a time.  Let's try stepping in first: type the F1 key.
  144.     The cursor jumps to location GET_HEX, on the same disassembly
  145.     screen.  The SP register decrements from FFFE to FFFC, and a
  146.     value 0106 appears on the stack.  This is the return address,
  147.     pointing to the instruction following CALL GET_HEX.
  148.  
  149. 14. Watch memory lines 1 and 2 as you press F1 again, single
  150.     stepping the LODSB instruction.  You had set up the lines to
  151.     be pointed to by SI.  Since SI changes when LODSB is
  152.     executed, the memory displays advance to the next byte. Note
  153.     that the AL register contains the value hex 20, a blank.
  154.  
  155. 15. In a normal debugging session, we would continue stepping
  156.     within GET_HEX, but let's not do that right now.  Instead,
  157.     press the F6 "TrapRet" key, which starts the program going,
  158.     trapping at the return address on top of the stack, which was
  159.     0106.  The cursor jumps back up to location 0106, the value
  160.     is no longer on the stack, and SI and the memory displays
  161.     have advanced to 0084.
  162.                                                               2-4
  163.  
  164. 16. Let's try the classic "G" command, common to all debuggers.
  165.     Type the line "G,0103", noticing the help windows as you go
  166.     along.  After you press ENTER, the program runs until it gets
  167.     back to the trap address you provided, 0103. Note that the
  168.     program has called OUT_VALUE to output the "A" that
  169.     corresponds to your input hex 41.  The "A" appears on the
  170.     bottom line, and the blinking cursor advances.
  171.  
  172. 17. Let's execute the next CALL GET_HEX all at once, by pressing
  173.     the F2 ProcStep key.  SI advances again, and AL is loaded
  174.     with the next value 42.
  175.  
  176. 18. Notice that the disassembly is symbolic: the display is CALL
  177.     GET_HEX, not CALL 0112 as lesser debuggers might give you.
  178.     Let's try symbolic input: type the line "B,HEX_DIGIT?",
  179.     causing the debugger to set a fixed trap at location
  180.     HEX_DIGIT?.  Now set your program running with a simple G
  181.     followed by the ENTER key.  The program traps at HEX_DIGIT?.
  182.     Since this location is not in the disassembly window, the
  183.     window is regenerated, and the cursor placed at HEX_DIGIT?.
  184.     The memory displays now point to the final number "5A".
  185.  
  186. 19. Press F3 to repeat the G-command.  The program traps at
  187.     HEX_DIGIT? again, with SI advanced to the "A".  Press F3
  188.     again; advancing SI to the final carriage return.
  189.  
  190. 20. Press F3 yet again.  Since HEX_DIGIT? is never reached again,
  191.     the program runs to its completion.  D86 automatically traps
  192.     at the EXIT instruction: in this case, it is INT 021 with the
  193.     AH register set to hex 4C, the function number for EXIT.  If
  194.     we try to start the program again from here, we will be
  195.     frozen here: we must issue the Q command to exit the session.
  196.     Don't do it yet, though.
  197.  
  198. 21. Before exiting, let's check out HEX_DIGIT? more thoroughly.
  199.     First, we clear the breakpoint we set, by typing "B" followed
  200.     by the ENTER key.
  201.  
  202. 22. Type the command line "J 0200", jumping to a scratch-pad
  203.     memory area.  Then press the F7 key, entering Patch Memory
  204.     mode.  The cursor moves into the disassembled instruction,
  205.     signalling that whatever you type is clobbering it.
  206.  
  207. 23. Type in the lines "INC BL", "MOV AL,BL", and "JMP
  208.     HEX_DIGIT?".  Press ENTER at the beginning of the fourth
  209.     line, exiting Patch Memory mode.  The cursor will return to
  210.     the left of the 0200 INC BL line.
  211.  
  212. 24. Type the immediate command "MOV BL,'0'-2".  The BL register
  213.     should change to the evaluated value, hex 2E.
  214.                                                               2-5
  215.  
  216. 25. Execute the patch subroutine by typing the line "CALL 0200".
  217.     The value BL increments to 2F, which is one less than the
  218.     lowest digit, '0'.  The Carry flag is set, indicating that
  219.     HEX_DIGIT? has correctly judged 2F not to be a hex digit.
  220.     Now press F3 repeatedly, executing your patched subroutine
  221.     for each decimal digit.  The "c" will disappear as the values
  222.     advance; and AL will hold the correct binary value for each
  223.     hex digit BL.  When BL reaches 3A, the "c" comes back on
  224.     again, indicating that we are beyond the decimal digits.
  225.     When BL reaches 41, "c" goes off, and AL values of 10 through
  226.     15 are displayed.  When BL reaches "47" "c" comes on yet
  227.     again, because G is not a decimal digit.  Type "MOV BL,05F",
  228.     followed by "CALL 0200", followed by F3 several more times to
  229.     verify correct action for the range of lower case 'a' through
  230.     'f'. You have, relatively quickly, done a thorough test of
  231.     HEX_DIGIT?.  How long would that have taken on a lesser
  232.     debugger?
  233.  
  234. 26. Type Q followed by ENTER to exit the debugger.
  235.  
  236.