home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / asmutil / d86v322.zip / D03.DOC < prev    next >
Text File  |  1990-01-25  |  16KB  |  378 lines

  1. CHAPTER 3   REQUIREMENTS AND OPERATION
  2.  
  3.  
  4. System Requirements for D86
  5.  
  6. D86 currently requires either an IBM-PC or compatible computer, a
  7. Texas Instruments TI-PC, a Wang PC, a Tandy 2000, a DEC Rainbow,
  8. or a Sanyo 550 or 555 computer. The computer must be running
  9. MS-DOS V2.00 or later.  The IBM compatibility must exist at the
  10. BIOS and video interface levels: D86 calls the BIOS to obtain
  11. keystrokes and video status information; and, on an IBM-PC, D86
  12. writes directly to video memory at segment 0B000 (if the BIOS
  13. says monochrome) or 0B800 (if color).
  14.  
  15. I will be happy to work with you to add support for your
  16. non-IBM-PC compatible MS-DOS computer.  See the end of this
  17. chapter for the first steps in helping me do so.
  18.  
  19. D86 is fairly flexible about memory management.  If there is
  20. enough memory, D86 will take the combined sizes of D86.COM and
  21. A86.COM (currently about 38K bytes), plus 64K bytes for its own
  22. stack, and leave the rest for the program being debugged.  If
  23. memory is tight, D86 will reduce the memory allocated to its own
  24. stack, down to a minimum of 16K bytes.  The segment occupied by
  25. the program being debugged will be similarly reduced.  If the
  26. program is a COM file, you can tell this by the initial SP value,
  27. which is 0FFFE if there is a full 64K, less if there isn't.
  28. Thus, D86 will work with as little as 70K bytes beyond the
  29. operating system; but the symbols capacity and the program's
  30. memory will be severely limited in that case.  It is best to have
  31. at least 166K bytes of memory available when D86 is running.
  32.  
  33.  
  34. Invoking D86
  35.  
  36. You invoke D86 by issuing the command
  37.  
  38.    D86 [+V] [progname [command-tail]]
  39.  
  40. where progname is the name of the program you are debugging.  In
  41. other words, you type a program invocation line just as if you
  42. were about to execute the program without a debugger, except that
  43. you append D86 before the line.
  44.  
  45. The following sections describe in detail the elements of the D86
  46. invocation line, and how D86 acts on them.
  47.  
  48.  
  49.  
  50. Finding the Program File
  51.  
  52. On most other debuggers, you have to give the full file name,
  53. with an explicit extension and a specific directory.  With D86,
  54. you don't: D86 uses almost the same algorithm for locating a
  55. program file that COMMAND.COM does:
  56.  
  57. 1. Look for COM, then EXE, then BAT in the current directory.
  58.                                                               3-2
  59.  
  60. 2. Look for COM, then EXE, then BAT in each directory in turn
  61.    given in the PATH environment variable.
  62.  
  63. The one difference is that D86 will look only for one extension
  64. if you give an explicit extension (and it doesn't have to be COM,
  65. EXE, or BAT).  COMMAND.COM ignores the extension you give-- I
  66. thought that was just too absurd, and didn't duplicate it.
  67.  
  68. A strange feature that I did duplicate is COMMAND.COM's lack of
  69. concern for whether the program is named COM or EXE.  If the
  70. program file begins with a valid EXE header, it's treated as an
  71. EXE no matter what it is named.  If not, then it's treated as a
  72. COM file.
  73.  
  74. D86 provides limited support for BAT files.  (That's better than
  75. other debuggers, which provide no support.)  If your program is a
  76. BAT file, D86 reads the first line of the file and pretends that
  77. that was what you typed following "D86" in your invocation.  The
  78. D86 status screen (gotten via Ctrl-S) gives you this line, and
  79. tells you what BAT file it came from.
  80.  
  81. The BAT file limitations are that D86 doesn't skip over remark
  82. lines, doesn't substitute batch-file parameters, and doesn't
  83. perform console redirection specified in the batch-file line.
  84.  
  85. You can also invoke D86 with no progname.  The debugger comes up
  86. with no program loaded, allowing you to simply poke around the
  87. machine.
  88.  
  89. If D86 had a problem loading your program, you'll see all NOPs in
  90. memory instead of instructions.  You can type Ctrl-S to get the
  91. status screen that tells you what the problem was.
  92.  
  93.  
  94.  
  95. Finding the Symbols File
  96.  
  97. D86 is a symbolic debugger.  It uses a special .SYM file produced
  98. in one of three ways:  First, if your program was produced by
  99. A86, then the .SYM file was produced by A86 at the same time.
  100. Second, if your program was produced by a high-level language
  101. such as Pascal or C, you can feed the linker's .MAP listing to
  102. the special MAPD86 tool, available to registered D86 users only.
  103. Third, you can "reverse engineer" a program by adding symbols
  104. while in D86's patch mode, then create a .SYM file with D86's W
  105. command.
  106.                                                               3-3
  107.  
  108. When invoked, D86 looks for a file with the program's name and a
  109. .SYM extension.  D86 first looks in the current directory for
  110. this file, and then in each directory specified in the PATH
  111. environment variable.  It is not necessary for the SYM file to
  112. exist.  If there is no SYM file, the debugger simply comes up
  113. with no user symbols defined.  You'll also get no user symbols if
  114. the SYM file was not of a correct format (it wasn't produced in
  115. one of the ways mentioned in the previous paragraph, or it has
  116. been corrupted in some way).  If you were expecting symbols and
  117. didn't get any, you can press Ctrl-S to get the status screen
  118. that tells you what the problem was.
  119.  
  120.  
  121. Two-Screen Debugging with +V
  122.  
  123. The +V option can be used if you have both a monochrome and a
  124. color monitor.  You invoke D86 when the operating system is on
  125. one monitor-- with the +V switch, the debugger will appear on the
  126. other monitor, and program console output will appear on the
  127. operating system's monitor.
  128.  
  129. In order for the +V option to work, you must initialize both
  130. screens by MODEing to them sometime after powering up the
  131. machine. You should also make sure that the blinking cursor is at
  132. the bottom of the screen on which the debugger will appear (the
  133. simplest way to do this is to type ENTER until the prompt gets to
  134. the bottom).  If you can suppress the blinking cursor, that's
  135. even better.  See in your DOS operating manual for instructions
  136. on how to use MODE to switch between screens.  D86 doesn't do the
  137. initialization, because I couldn't figure out how to get the BIOS
  138. to do so without blanking the screen, and you might not want the
  139. screen blanked every time you start a D86 session.
  140.  
  141.  
  142.  
  143. The D86 Screen Display
  144.  
  145. When D86 starts up, it generates a full-screen display, and
  146. awaits your debugger commands.
  147.  
  148. In the top part of the screen is a symbolic disassembly of the
  149. A86 program, with the screen cursor positioned next to the
  150. instruction pointed to by the 8086 instruction pointer.
  151.  
  152. In the lower left corner is a fixed display of the complete 8086
  153. register set.
  154.  
  155. At the top of the second column of the register-set display is a
  156. display of the 8086 flags.  Each flag displays as blank if the
  157. flag is off; a lower case letter if the flag is on:
  158.                                                               3-4
  159.  
  160.      o   for overflow,
  161.      d   for direction,
  162.      i   for interrupts enabled,
  163.      s   for sign,
  164.      z   for zero,
  165.      a   for auxiliary carry,
  166.      e   for parity even, and
  167.      c   for carry.
  168.  
  169. Across the bottom line of the screen is a display of the contents
  170. of the user stack.  The display begins next to the SP register
  171. value, with the number of elements on the stack.  (The stack is
  172. assumed to have 0 elements when SP is at its original value,
  173. which is 0FFFE for COM files, and a value specified in the header
  174. record for EXE files). The number of elements is followed by a
  175. colon, followed by as many of the top stack elements as fits on
  176. the line.  The initial display will have zero elements; nothing
  177. is yet on the stack.
  178.  
  179. To the right of the registers are 6 lines, numbered 1 through 6.
  180. On these lines, you can generate windows into 8086 memory,
  181. displaying bytes, words, or ASCII text in a variety of formats.
  182. The windows can be located either at absolute memory locations,
  183. or be pointed to by any of the 8086 registers.  The commands you
  184. issue to generate these windows are described in Chapter 6.
  185.  
  186.  
  187. D86 Commands
  188.  
  189. There are 5 kinds of activities you perform in D86:
  190.  
  191.    1. Issuing assembly language commands for immediate execution
  192.  
  193.    2. Issuing debugger commands via lines that begin with a
  194.       single letter
  195.  
  196.    3. Issuing debugger commands via the function, Ctrl, and
  197.       cursor-control keys on your keyboard
  198.  
  199.    4. Setting up windows that display memory
  200.  
  201.    5. Issuing assembly language commands to enter into memory
  202.       (PatchMem)
  203.  
  204.  
  205.  
  206. Immediate Assembly Language Commands
  207.  
  208. A primary part of the D86 command language is the A86 assembly
  209. language. With it, you can jump to different areas of your
  210. program, set your registers, perform arithmetic, and call any of
  211. the procedures of your program.  Simply type in any legal A86
  212. instruction, and it will be executed immediately.
  213.  
  214. JMP and RET instructions cause the program counter (and thus also
  215. the disassembly) to move to the indicated destination.  CALL
  216. instructions cause the entire procedure to be executed.
  217.                                                               3-5
  218.  
  219. WARNING: The immediate-execution feature is a little tricky if
  220. you are in a multi-segment program, of if you jump to exotic
  221. parts of the 86 memory space (i.e., into MSDOS, ROM, video
  222. memory, or the interrupts table). This is because D86 needs a
  223. buffer in which to put the immediate-execution command.  The
  224. buffer should be in your program's CS segment, so that commands
  225. such as jumps and near calls execute correctly.  So D86 must
  226. always search in CS for a satisfactory buffer.  Here is how D86
  227. finds it:
  228.  
  229.   1. If you declare a label D86_BUFFER, pointing to a buffer
  230.      within your program, then D86 will use that buffer as the
  231.      offset for its immediate instruction.
  232.  
  233.   2. If not, then if the program's CS register is the same as its
  234.      SS register, D86 will use (SP-300) as its immediate buffer.
  235.      Thus, your stack should have plenty of room (a good practice
  236.      in general).
  237.  
  238.   3. As a last resort, D86 uses offset 00E0, which points to the
  239.      last 32 bytes of the Program Segment Prefix (PSP).  In that
  240.      case, if you were to issue an immediate command that reads
  241.      from a disk file, you would be in trouble, because the
  242.      disk-read operation clobbers the PSP, and the command would
  243.      not be trapped back to the debugger.
  244.  
  245.   In cases 1 and 3 above, the segment containing the buffer is
  246.   the program's CS segment, unless that is out of range (below
  247.   the program's original CS, or above the top of available
  248.   program memory).  If the program CS is out of range, the
  249.   program's original CS is used instead.  In that case, immediate
  250.   instructions such JMP, RET, and CALL will not work correctly.
  251.  
  252.   Note that the above caveats do not apply to single stepping.
  253.  
  254.  
  255.  
  256. Entering Instructions Into Memory
  257.  
  258. D86 allows you to alter 8086 memory in two ways: first, you can
  259. issue immediate assembly language commands which, when executed,
  260. store values in memory.  The other method is to enter a special
  261. mode, in which you enter instructions directly into 8086 memory.
  262.  
  263. You enter this mode by typing the F7 (PatchMem) key. The screen
  264. cursor jumps from the left edge of the line at the current
  265. program counter, into the middle of the line where the
  266. instruction is.  You start typing over the instruction, to signal
  267. that you are clobbering the instruction that was there.  If you
  268. did not intend to enter this mode, you can backspace back to the
  269. start of the instruction, and type a carriage return.
  270.  
  271. Each line you type in is checked for errors.  If there was an
  272. error, a message is displayed, the cursor remains at the same
  273. location, and you try again. If there was no error, the cursor
  274. moves beyond the newly-assembled line, and you can type in
  275. another line.
  276.                                                               3-6
  277.  
  278. To exit the memory programming mode, you type any of the control
  279. key commands at the beginning of the line.
  280.  
  281.  
  282. Entering Data into 8086 Memory
  283.  
  284. You can deposit data into the 8086 memory space by using the
  285. programming mode described in the above section.  Simply enter DB
  286. and/or DW statements instead of instructions.  Note that ASCII
  287. strings can be entered with the DB instruction; and that arrays
  288. can be initialized via the DUP operator in a DB or DW statement.
  289.  
  290.  
  291. Adding Symbols to a Program
  292.  
  293. Patch mode also allows you to do something that you cannot do in
  294. immediate execution mode: add symbols to the program.  You can do
  295. so by either:
  296.  
  297.    1. Typing in a new symbol name, followed by a colon; or
  298.  
  299.    2. Typing in an EQU directive.
  300.  
  301. There are several uses for this.  First, you might want to create
  302. an abbreviation, by equating a short name to a long one, or to a
  303. hard-to-remember constant value.  Second, you might want to
  304. "reverse engineer" a program for which you have a .COM file, but
  305. not the A86 source code.  Each time you add a label, the
  306. disassembly becomes more readable.  Third, you might want to
  307. label code that you have added in patch mode.
  308.  
  309. After you have added symbols to the table, you can save the
  310. resulting expanded table with the W command.  Simply type W
  311. followed by the ENTER key at the main debugger command level.
  312.  
  313. Forward referencing is allowed when you are in patch mode.  You
  314. must be careful, however, to resolve any forward references you
  315. have made.  In particular, you will cause the assembler to become
  316. very confused if you overwrite a forward reference with some
  317. other code before you resolve the reference.  So don't!
  318.  
  319.  
  320.  
  321. What to Do if D86 Doesn't Work on Your Computer
  322.  
  323. If D86 does not work properly on your system, I would like to
  324. hear about it.
  325.  
  326. If you saw no debugger screen at all when you tried executing D86
  327. HEXOUT, try D86 +V HEXOUT.  Let me know what happens then.
  328.  
  329. I have written a tool called D86CHECK, that outputs information
  330. about your computer system.  Please run D86CHECK to get that
  331. information.  If you are sending me a letter in the mail, you can
  332. direct output to your printer; e.g., D86CHECK >PRN.  If you are
  333. sending me a disk, or a message on the bulletin board, you can
  334. redirect output to a file; e.g. D86CHECK >OUTFILE.
  335.                                                               3-7
  336.  
  337. Give me the output to D86CHECK, and tell me as much as you can
  338. about the problems you are experiencing.  Also tell me the brand
  339. and model of your computer.  I'll try to see to it that the
  340. problem is fixed.
  341.  
  342. Again, my phone number is (812)339-1811.  I also receive BBS mail
  343. at (812)855-7252 and (812)332-7227.  My address is:
  344.  
  345.    Eric Isaacson
  346.    416 E. University Ave.
  347.    Bloomington, IN 47401-4739
  348.  
  349.  
  350. If You'd Like to Be Ambitious
  351.  
  352. If you are skilled in assembly language programming, you can
  353. write the BIOS interface routines for D86 yourself, and send them
  354. to me.  That's probably the quickest way you'll get D86 up on
  355. your computer.  To do this, you need to get the files XBIOS.8 and
  356. BIOS.8.  These files are included in the D86 package for versions
  357. V3.11 and earlier.  I deleted them starting with V3.12, to make
  358. room on the distribution diskette; but they are still available
  359. in the file D86BIOS*.ZIP (where * is a digit that will increment
  360. with new versions).  The file can be downloaded from either of
  361. the BBS systems listed in the previous section.
  362.  
  363. You must add code to BIOS.8 to detect your machine, take a BIOS
  364. keystroke, ring the bell, and copy to your video memory.  If you
  365. do not feel up to actually making the modifications yourself,
  366. then you can send me sufficient documentation about your
  367. computer, that would let me do so.  If you do not know where such
  368. documentation exists, ask your computer dealer or your user's
  369. group.
  370.  
  371. IMPORTANT NOTE: My efforts in porting D86 are done with the
  372. understanding that you will become a registered user.  I would
  373. prefer that you register in advance; if this makes you nervous,
  374. then I will accept a written promise from you that you will
  375. register when I get D86 working on your machine.  (Advance
  376. registrants will get the fastest turnaround.)
  377.  
  378.