home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug034.arc / ZZSOURCE.DOC < prev   
Text File  |  1979-12-31  |  27KB  |  798 lines

  1.         ZESOURCE
  2.  
  3.  
  4. *************************************************************
  5. MICRO CORNUCOPIA NOTE: I didn't have a copy of ZZSOURCE.DOC
  6. so this is a copy of ZESOURCE.DOC. ZESOURCE is an extension 
  7. of RESOURCE for TDL mnemonics and this is a further extension
  8. that provides Zilog mnemonics. (You don't know how I've looked
  9. for this). Anyway, if anyone has the real ZZSOURCE.DOC,
  10. please let me know where it is so I can offload it or please
  11. send it in.
  12.  
  13. Dave Thompson
  14. ***************************************************************
  15.  
  16.     A disassembler for Z80 programs
  17.     by Dave Barker
  18.     (from RESOURCE by Ward Christensen)
  19.  
  20. {NOTE:  Most of the text of this file was written by Ward
  21. Christensen.  I have modified or added to it to make it agree
  22. with the features of ZESOURCE, which is RESOURCE enhanced to
  23. disassemble into TDL Z80 mnemonics.}
  24.  
  25.  
  26. Suggestions?  Call me eve's at (805) 526-2438 (D.Barker)
  27.         ----------------
  28. ZESOURCE commands are inconsistent at best. - ZESOURCE is a 
  29. kludge based on years of disassembler experience and hacking, 
  30. and was never "planned" - just coded sitting at a tube, and
  31. modified over 2 years before being contributed to the CP/M UG.
  32.  
  33. For example, to kill a symbol: k.label   but to kill a 
  34. control value: caddr,k and to kill a comment: ;addr,
  35. but ZESOURCE does the job like no other I have seen.
  36.         ----------------
  37. N-O-T-E: Pardon the editorial, but I feel hardware without
  38. good software is useless to 99% of us.  Most good software
  39. has to be paid for.  I strongly support the legitimate purchase
  40. of licensed software.  I do not regularly use any programs
  41. which I have not purchased.  (Yes, I do occasionally "try"
  42. one, but then buy it if I plan on using it).  I have been
  43. asked by software businesses to NOT distribute ZESOURCE -
  44. because of it's ability to produce good .asm source quickly.
  45. But, there are so many disassemblers out, why not a good, 
  46. conversational one?   Please use it in the spirit in which it 
  47. was contributed: to enlarge your understanding of the micro-
  48. computer world around you, and to allow you to customize 
  49. programs which you legitimately own, for your own use.
  50.  
  51.     "Semper non rippus offus"
  52. ----
  53. NOTE: any command taking a hex address (Dnnnn, etc)
  54. may take a value in the form .label but arithmetic
  55. may not be performed.  (i.e. d.start is ok, but d.start+8 not)
  56.         ----------------
  57.     Overall structure of ZESOURCE:  It is a .COM file,
  58. which runs at 100H.  It goes thru 1C00 or so, then the stack.
  59. At 1D00 is a 512 entry table for control commands.  Each is
  60. 3 bytes long, and controls the format of the re-sourced list,
  61. i.e. is it DB, DS, DW, instructions, etc.
  62.     At 2300 is the start of the symbol table.  It has no
  63. defined length as such.  If it is not used, it occupies only
  64. 2 bytes.
  65.     If you want to re-source something which is in memory,
  66. such as a PROM, a program previously loaded in high memory,
  67. "CP/M itself", or whatever, you can just do so.
  68.     However, typically you want to disassemble a program
  69. which runs at 100H, which is were ZESOURCE runs.   Bob
  70. Van Valzah would have solved that by making resource
  71. relocatable and moving itself up under BDOS.  I wasn't that
  72. industrious.
  73.     Instead, ZESOURCE uses the concept of an "invisible"
  74. OFFSET.  After all, what do you care where it is as long
  75. as it LOOKS like it's at 100h?
  76.     So, you set an offset.  O2F00 sets it to 2F00 Hex.
  77. Reading a .COM file (RFOO.COM) causes it to come into 3000 on.
  78. If you say D100 or L100 it dumps or lists what LOOKS like your
  79. program.  Internally, ZESOURCE is adding the offset to the
  80. D and L addresses.
  81.     What should you set the offset to?  Well, that depends
  82. upon how many symbols you will use.  O2400 will load the
  83. program at 2500, thus allowing only 2300-24FF for symbols,
  84. i.e. 512 bytes or about 50-60 labels.  If you didn't leave
  85. enough space, then used B to build a default symbol table,
  86. the table could run into and clobber your .com file!  (easy
  87. recovery, however: just change the offset to being higher,
  88. and read in the .COM file again)  Each entry takes 3 bytes
  89. + the symbol length, and if you like 7 byte labels like I
  90. do, that means 10 bytes/label.  An offset of 2F00 should
  91. be adequate.
  92.     If you want to put comments into the disassembled
  93. program, you will have to designate an area to Use for the
  94. comments.  The U command (e.g. U4000) specifies what area
  95. is to be used.
  96.     Before issuing the O (offset) command, do:
  97.     L5 7
  98. which will show the JMP to BDOS, which is the highest memory
  99. you may use.  (Note if you have, for example, an empty 4K
  100. memory board in high memory, you can Use THAT for comments).
  101.     Let's take an example:  You have an 8K file, FOO.COM
  102. which you want to disassemble.  It will have about 300 labels.
  103. 300 x 10 is 3000, or call it 4K (what's a K unless your
  104. tight).  The symbol table starts at 2300.  4K more is 3300.
  105. Let's load the .COM at 3300, so since it normally starts
  106. at 100H, the offset is 3200.  O3200 is the command.
  107. We then RFOO.COM to read it in.  It says 5300 2100 which
  108. means it came into actual memory to 5300, but 2100 if we
  109. are talking with respect to loading at 100.
  110.     Thus, we could set our comments table up after
  111. the .COM program - say at 6000:  U6000
  112.     The ? command shows the memory utilization for
  113. control, symbol, and comments entries.  (no, I never put
  114. in anything to keep track of the .COM - you'll just have
  115. to do that yourself).
  116.     If you ever want to dump real memory, you'll have
  117. to reset the offset to 0: O0  but then set it back.
  118. If you are not sure what it is, typing O will tell the
  119. current offset.
  120.  
  121.     Hoo, boy!  Hope this kludge of documentation
  122. is enough to get you going - hmmm, better give you
  123. some of the gotcha's I've discovered...
  124.  
  125.         ---- WATCH FOR ----
  126.  
  127. *    Symbols overflowing into the .COM.
  128.     (Use ? command to see how full symbol table is)
  129.  
  130. *    Control entries overflowing into .SYM (altho I
  131.     can't believe anyone will have a program with
  132.     more than 512 control entries!!!)
  133.  
  134. *    Comments overflowing into BDOS (ug!!)
  135.  
  136. *    Using an offset which is not in free memory
  137.     and overlaying BDOS or whatever.
  138.  
  139. *    The B(uild) command gobbling up too much when building
  140.     a DB:  "B" will take a DB 'GOBBELDY GOOK' followed
  141.     by LXI H,FOO and take the LXI as a '!' (21H) so
  142.     you'll have to manually stick a new "I" control
  143.     entry in at the address of the LXI.  You might
  144.     also delete the incorrect "I" entry which ZESOURCE
  145.     stuck in (typically at the second byte of the LXI)
  146.  
  147. *    Trying to dump real memory without setting the
  148.     offset back to 0.  (then forgetting to set it back
  149.     to its proper value)
  150.  
  151. *    Forgetting how big the .COM file you are disassembling
  152.     was.
  153.  
  154. *    Using ZESOURCE to rip off software (yes, I know, you
  155.     heard that before, but only 3 in 100 needed to be 
  156.     told, and 2 in 100 needs to be told again, and 1 in
  157.     100 doesn't give a rat's fuzzy behind anyway!!)
  158.  
  159. *    Forgetting to take checkpoints when disassembling
  160.     large files.  You may even want to rotate the names
  161.     under which things are saved:
  162.  
  163.     STEMP1.SYM
  164.     STEMP1.CTL
  165.     STEMP1.DOC
  166.  
  167. *    Missing a label:  Suppose you have a control entry
  168.     for a DW, resulting in:
  169.     
  170.     DFLT:        ;172C
  171.         DW    100H
  172.  
  173.     but somewhere in the program, the following exists:
  174.  
  175.         LDA     172DH
  176.  
  177.     Even if you did a B and have a label L172D, it won't
  178.     show up since it's in the middle of a DW.  Instead,
  179.     do this:
  180.  
  181.     K.l172d        kill the old label
  182.     e172d,.dflt+1    put in the new label as a displacement
  183.             off the beginning.
  184.  
  185. *    improperly disassembling DW's (see previous item).
  186.     You might be tempted to make DFLT a DB so that
  187.  
  188.     DFLT:        ;172C
  189.         DB    0
  190.     L172D:        ;172D
  191.         DB    1
  192.  
  193.     Note that while this disassembles and reassembles
  194.     properly, it is not "as correct" as the technique
  195.     used in the previous item.
  196.  
  197. *    Having the "B" command overlay your "E" control entry.
  198.     What?  Well, "B"uild is pretty dumb.  If he finds 8
  199.     DB type characters in a row, he fires off a DB from
  200.     then on until he runs out of those characters.  Suppose
  201.     your program was 200 long (ended at 3FF), and you
  202.     had zeroed (aha!  Nice DB candidates) memory there
  203.     (there meaning at your offset address + whatever).
  204.  
  205.     Then you QB100,400 and viola!!  ZESOURCE overlaid
  206.     your "E" control with a "B".  
  207.         ----------------
  208.  
  209.     ZESOURCE is relatively complete.  (well, actually,
  210.     the phrase "rampant featureitis" has been "mentioned").
  211.     ...But there's always another day, and another K...
  212.  
  213.         SO... Here's my "wish list"
  214.  
  215.     ..it might save you telling me YOU think such-and-such
  216.     would be nice...
  217.  
  218. *    Targets of LHLD, SHLD should automatically be flagged
  219.     as type DW in the control table.  Ditto LDA and STA
  220.     as DB or as second half of DW.  Ditto targets of LXI
  221.     as DB (?).
  222.  
  223. *        E5C,.FCB
  224.     followed by
  225.         E6C,.FCB+
  226.     should automatically calculate the appropriate
  227.     displacement, and put it in the symbol table.
  228.  
  229. *    The comments facility should be enhanced to allow
  230.     total SUBSTITUTION of entire line(s) of the code,
  231.     i.e. at address such-and-such, replace the next 3
  232.     bytes with the following arbitrary line.  This
  233.     would help those "how do I explain what was being
  234.     done" cases such as:    LXI    H,BUFFER AND 0FF00H
  235.  
  236.         ----------------
  237. ZESOURCE types an "*" prompt when it is loaded.  You may
  238. then enter any of the following commands.  Each command
  239. is a single letter followed by operands.  Commas are shown
  240. as the delimiter, but a space will also work.
  241.  
  242.         ----------------
  243.         ----------------
  244. ;    Put comments into the program.
  245.     (must execute 'u' command first, to assign area
  246.     for comments to be placed)
  247.  
  248.     ;addr,comment    enter a comment
  249.     ;addr        lists existing comment
  250.     ;        lists entire comments table
  251.     ;addr,        deletes existing comment
  252.  
  253.     note that '\' is treated as a new line, i.e.
  254.     \test\ will be formatted:
  255.  
  256.     ;
  257.     ;TEST
  258.     ;
  259.         ----------------
  260. Attempt to find DB's while listing the program.
  261. -    This command works just like 'L', but attempts
  262.     to find DB's of 8 chars or longer.
  263.  
  264.     (see 'L' command for operand formats)
  265.         ----------------
  266. Build default sym tbl (LXXXX) labels for each
  267. -    2 byte operand encountered.  Note 'B' is
  268.     identical to 'L' except labels are built.
  269.  
  270.     (see 'L' command for operand formats)
  271.         ----------------
  272. Control table usage:
  273. -    c        dump ctl tbl
  274.     cnnnn        dump from starting
  275.     cnnnn,x        define format from nnnn
  276.             to next entry.  values of x:
  277.  
  278.             B = DB (attempts ASCII
  279.                 printable, 0DH, 0AH, 0)
  280.             W = DW (attempts label)
  281.             S = DW to next ctl entry
  282.             I = instructions
  283.             K = kill this ctl entry
  284.             E = end of disassembly
  285.  
  286.     NOTE every control entry causes a "control break"
  287.     (NO, ZESOURCE was NOT written in RPG) which means
  288.     a new line will be started.  Thus if you have a
  289.     string in memory which disassembles as:
  290.  
  291.     DB    'Invalid operand',0DH
  292.     DB    0AH
  293.  
  294.     You might want to change it putting the 0DH,0AH
  295.     together on the second line - just enter a "B"
  296.     control entry for the address of the 0DH.
  297.  
  298.     The same technique could be used to make
  299.  
  300.     DB    'TYPESAVEDIR ERA REN '
  301.  
  302.     appear as
  303.  
  304.     DB    'TYPE'
  305.     DB    'SAVE'
  306.     DB    'DIR '
  307.     DB    'ERA '
  308.     DB    'REN '
  309.  
  310.         ----------------
  311. dump:
  312. -    dxxxx        Dumps 80H from xxxx on
  313.     daaaa,bbbb    Dumps from aaaa thru bbbb
  314.     d,bbbb        Continues, thru bbbb
  315.     d        Continues, 80H more
  316.  
  317.     NOTE 80H is the default dump length.  If you have
  318.     a larger display, you can change the default via:
  319.  
  320.     d=nn        nn is the HEX new default.
  321.  
  322.     For example, a 24 line tube could display 100H:
  323.  
  324.     d=100        or..
  325.     d=100,200    Defaults to 100, dumps 200-2ff
  326.  
  327.         ----------------
  328. enter symbol:
  329. -    ennnn,.symbol     symbol may be of any length,
  330.             and contain any char A-Z or 0-9,
  331.             or "+" or "-".  This allows:
  332.             E5D,.FCB+1.  Note the "+" is not
  333.             checked, i.e. E5D,.FCB+2 would be
  334.             wrong (assuming FCB is at 5C) but
  335.             would be allowed to be entered.
  336.  
  337.     Note when a new symbol is entered any ather symbol 
  338.     at that address will be killed.  This prevents having
  339.     two symbols with the same address.  If you have a label
  340.     which has the wrong address, you need not explicitly
  341.     kill the old one before entering the new.  A label
  342.     which is spelled exactly the same as an existing one
  343.     will replace the existing one even if the addresses
  344.     are different.
  345.         ----------------
  346. Find occurrence of address or label.  Note this function
  347. -    runs until interrupted (press any key).
  348.     fnnnn,ssss    find address nnnn in memory.  Start
  349.             the search at ssss.  Runs forever.
  350.             Press any key to stop.
  351.     f        continue previous find command
  352.       fnnnn        find nnnn starting at address you last
  353.             stopped at in the f command
  354.         ----------------
  355. kill symbol from table
  356. -    k.symbol
  357.         ----------------
  358. list (disassemble).  This command is used to list the
  359. -    file, or to list it to disk after enabling
  360.     the .ASM file save via 'SFILENAME.ASM' command
  361.  
  362.     l        lists 10 lines from prev pc
  363.     lssss,eeee    lists from ssss to eeee
  364.     l,eeee        lists from current pc to eeee
  365.     lssss        lists 10 lines at ssss
  366.  
  367.     Note that if you have a control 'e' entry, then the
  368.     list will stop when that address is found.  This allows
  369.     you to 'lstart,ffff'. 
  370.  
  371.     The 10 line default may be changed via:
  372.  
  373.     L=nn        where nn is a HEX line count, e.g.
  374.     L=14        set to 20 lines/screen
  375.  
  376.     You can change the default and list, e.g.
  377.  
  378.     L=9,100        Dflt to 9 lines, list at 100.
  379.  
  380.     NOTE when using L to list the .ASM program to disk,
  381.     you should either list the entire program at once
  382.     using: Lssss,eeee or, you can list small pieces
  383.     at a time.  As long as you list again without
  384.     specifying a starting address, (L or L,nnnn) then
  385.     the output file will continue uninterrupted.
  386.  
  387.     You may do dump commands, and others, without
  388.     affecting what is being written to disk.
  389.         ----------------
  390. offset for disassembly
  391. -    o        print current offset
  392.     onnnn        establish new offset
  393.  
  394.     (note the offset is always added to any 
  395.     address specified in an a, b, d, or l command.
  396.     to dump real memory, the offset must be reset to
  397.     0 (O0) before the dump.)
  398.         ----------------
  399. prolog generation - this routine generates an
  400. -    ORG instruction, and equates for any label
  401.     outside of a given low-hi address pair.
  402.     (the start and end addresses of your program).
  403.     e.g. if disassembling from 100 to 3ff, it will
  404.     generate 'fcb equ 5ch' if FCB is in the symbol
  405.     table.  In typical use, you would 'sfilename.asm'
  406.     then use the P command to write the prolog, then
  407.     the L command to write the program itself.
  408.  
  409.     Pstart addr,end addr
  410.     
  411. quiet command: any command which is preceeded by a q
  412. -    will be done 'quietly'.  For example, to save
  413.     a .asm program, you could just do:
  414.  
  415.     ql100,3ff    or    ql100,ffff if you have
  416.     set the 'e' control in the control table.
  417.  
  418.     Another use is to build a default symbol table
  419.     by taking a pass thru the program: QB100,xxxx
  420.         ----------------
  421. read .com, .ctl, .sym, or .doc file
  422. -    rfilename.com    reads in at offset+100h
  423.     rfilename.ctl    loads the ctl table
  424.     rfilename.sym    loads the sym file
  425.     rfilename.doc    loads the comments table (note
  426.             'u' command must have been issued)
  427.     rfilename.all    loads the doc, sym, and ctl files with
  428.             one command
  429.         ----------------
  430. save .asm, .ctl, .sym, or .doc file
  431. -    sfilename.asm    use 'l' command to write, z to end
  432.     sfilename.ctl    saves the ctl table
  433.     stablename.sym    saves the sym file
  434.     sfilename.doc    saves the comments table
  435.     sfilename.all    saves the doc, sym, and ctl files with
  436.             one command
  437.         ----------------
  438. use area of memory for comments table
  439. -    unnnn        such as ud000 if you had an
  440.             open board at 0d000h
  441.         ----------------
  442. purge sym tbl and CTL tbl
  443.     x
  444.     -
  445.         ----------------
  446. close .asm file (note that a preferred way to close the
  447.     .asm file is to have specified a control entry
  448.     for the end address (e.g. c1ff,e))
  449.     z
  450.     -
  451. --------------------------------------------
  452. --------------------------------------------
  453. Here is a sample of the ZESOURCE usage.
  454.  
  455. Given:    a COM file (lets say test.com) which runs at 100
  456.     (as any good COM file should), and goes thru 2FF.
  457.  
  458. lines preceeded with ---> are typed by you.
  459.  
  460. ---> ZESOURCE
  461. ---> o2200    set the offset to 2200, which means the
  462.         program will read into 2200 + 100 = 2300.
  463.  
  464. ---> rtest.com    reads the com file into memory. system says:
  465.         2500 0300 which is the actual hi load addr,
  466.         (2500) and the original hi load addr (300)
  467.  
  468.         REMEMBER this address (300) because you might
  469.         want to put a "E" (end of assembly) control
  470.         entry there.
  471.  
  472. <<<<note>>>> that all 'L' (disassembly list) and 'D' (dump)
  473.     commands work with the offset added.  Thus, you
  474.     should learn to forget that the disassembler is
  475.     in memory, and think of it as if your program were
  476.     actually at 100.  D100 will dump your program.
  477.     
  478.     also note:  if the program being "ZESOURCEd" will
  479.     have a fairly large symbol table, then you will
  480.     have to set the offset higher: o2f00 or some such.
  481.     (the ? command will show symbol table usage: if your
  482.     symbol table is nearing the .com file, then just
  483.     set a new offset (higher) and re-load the .com)
  484.  
  485.     if you want to dump r-e-a-l memory, you would have
  486.     to reset the offset to 0: o0  (but don't forget to
  487.     reset it to 1f00 before continuing with your program.)
  488.  
  489. If you are disassembling something which is in memory at
  490. it's correct address (such as looking at ccp) then don't
  491. set the offset.  It defaults to 0 when dis is first loaded.
  492.  
  493. --->    l100    list your program - lists "about" 10 lines.
  494.  
  495. --->    d100    do a dump of your program.
  496.  
  497. NOTE that typically here are the steps to disassembling
  498.     a program which has just been read into memory:
  499.  
  500. Use the dump command to find the ASCII DB areas.
  501.  
  502. Note that the 'a' command may be used to automatically
  503. find the db's, but you must then check them to insure
  504. that they don't extend too far.  All printable characters,
  505. 0dh, 0ah, and 00h are considered candidates for ascii db's.
  506.  
  507. At least 8 characters in a row must be found to make sure
  508. that long sequences of mov instructions won't be taken
  509. as db's.
  510.  
  511. Use the cnnnn,k command to kill erronious entries put
  512. in the control table by the a command, but then immediately
  513. put in the right address, such as via cnnnn,i
  514.  
  515. if you wanted to scan the program for ascii db's yourself,
  516. use the 'c' (control) command to set the beginning and
  517.     end of ascii areas.  F    JZ    078BH
  518.     XRA    A
  519.     STA    1712H
  520.     STA    1714H
  521.     CALL    1647H
  522.     CMC
  523.     DCR    C
  524.     LDAX    B
  525.     NOP
  526.     JMP    0177H
  527. L01F8:        ;01F8 
  528.     CALL    L1647    ;16 dump as:
  529.  
  530. 0100  c3170144 4f50xxxx  xxxxxxxx xxxxxxxx  *...copyr ight....*
  531. 0110  xxxxxxxx xxxxxxxx  xxxxxxxx xxxxxxxx  *xxxxxxxx ........*
  532.  
  533.  
  534. thus you would want to instruct the disassembler to switch
  535. to db mode at 103, and back to instruction mode at 117, thus:
  536.     c103,b
  537.     c117,i
  538.  
  539. Continue doing this, bracketing every ascii db which is in
  540. the middle of instructions, by a b control instruction
  541. and an i control instruction.  Note that multiple db's in
  542. a row need not have separate cnnnn,b instructions, but that
  543. these do cause a 'line break', i.e. if you have a table
  544. of ascii commands, for example:
  545.  
  546. 02e5    db    'load'
  547. 02e9    db    'save'
  548.  
  549. the disassembler would disassemble these as:
  550. 02e4    db    'loadsave'
  551.  
  552. you could put in an additional control entry: c2e9,b, which
  553. would cause the disassembler to generate:
  554.  
  555. 02e4    db    'load'
  556. 02e8    db    'save'
  557.  
  558. which is much more readable and realistic.
  559.  
  560. Note that before generating each byte of a db, a symbol
  561. table lookup is done to determine if there is a label
  562. at that location, and if so, a new line is started.
  563.  
  564. Thus if 'loadlit' and 'savelit' were in the symbol table,
  565. as the labels on the 'load' and 'save' above, no separate
  566. 'b' control instruction would be required as the label
  567. would cause the break.
  568.  
  569. <<<<NOTE>>>> that at this time the automatic label checking
  570. is n-o-t done for ds instructions.  Make sure that each
  571. ds instrucion references only up to the next label.  This
  572. means that multiple ds's in a row must each be explicitly
  573. entered into the control table.  Presence of a label is
  574. not sufficient.
  575.             ----
  576. steps, continued:
  577.  
  578. After building the control entries with cnnnn,b and cnnnn,i
  579. put in a control entry cnnnn,e which defines the address of
  580. the end of your program.  The l command will then automatically
  581. stop there, and in addition, if you are in 'save xxx.asm'
  582. mode, the output .asm file will be closed.  If you do
  583. mot define a control 'e' entry, then you will have to use
  584. the break facility to stop the l command (don't use control-c
  585. as that will re-boot cp/m).  If you were writing an .asm
  586. file, you would have to user the z command to close the
  587. file.
  588.  
  589. Next, you would list your program to determine how it looks.
  590. when you recognize a routine by it's function, insert a label.
  591.  
  592. For example, if you saw that location 7ef was a character
  593. out routine (type) then enter a label into the symbol table:
  594.     E7EF,.TYPE
  595.  
  596. NOTE that all symbols start with a '.', so as to be dis-
  597. tinguished from hex data.
  598.  
  599. NOTE that if you want the disassembler to make default labels
  600. for you, use b (for build labels) instead of l (for list
  601. program).  The b commands causes lnnnn default labels to
  602. be inserted in the symbol table for every 2 byte operand
  603. encountered (LXI, SHLD, JMP, etc).  It will undoubtedly
  604. make some you don't want, such as L0000.  You will have to:
  605.  
  606.     K.L0000        kill label L0000 from the table.
  607.  
  608. When you encounter data reference instructions, try
  609. to determine what type of area the instruction points to.
  610. Typically,, LXI instructions may point to a work area
  611. which should be defined as a DS, or to an ASCII string,
  612. in which case we will have already made it a 'b' control
  613. instruction.  Operands of LHLD and SHLD instructions
  614. should be made DW instructions.  For example if you
  615. encounter LHLD 0534H, then issue a control instruction:
  616.  
  617.     C534,W
  618.  
  619. NOTE that whatever mode you are last in will remain in
  620. effect.  Therefore if 534,w is the last entry in the
  621. control table, all data from there on will be taken to be
  622. DW's.
  623.  
  624. Suppose that you determine that address 7cf is a 128 byte
  625. buffer for disk I/O.  You want it to disassemble to:
  626.  
  627. DKBUF        ;07CF
  628.     DS    80H
  629.  
  630. You do this as follows:
  631.  
  632.     C7CF,S        to start the DS
  633.     C84F,B        to define it's end, and
  634.     E7CF,.DKBUF    to put the symbol in the table.
  635.  
  636. Continue, iteratively using the 'l' command and the 'c'
  637. and 'e' commands until you have the listing in a nice
  638. format.  You will then probably want to save the control
  639. symbol, and comments tables.  Or, you could have been 
  640. saving them at checkpoint times (so if you make a 
  641. major mistake you could go back to a previous one).
  642.  
  643. To save a control file:
  644.     sfilename.CTL    (any filename, may include a: or b:)
  645.  
  646. To save a symbol file:
  647.     sfilename.sym
  648.  
  649. To save a comments file:  
  650.     sfilename.doc    (not ".com" of course)
  651.  
  652. NOTE that the filetypes must be used as shown, but
  653. that any legal filename (or disk:filename such as b:xxxx.CTL)
  654. may be used.
  655.  
  656. You could now control-c to return to CP/M, and come back
  657. later to resume your disassembly:
  658.  
  659.     ZESOURCE
  660.     o2200
  661.     rtemp.com
  662.     rtemp.sym
  663.     rtemp.ctl
  664.     uxxxx        (such as u4000)
  665.     rtemp.doc
  666.  
  667. This will take you back exactly where you left off.
  668.  
  669. If you want to save a .asm file out to disk, do the following:
  670.  
  671. Make sure that there is a control entry defining the end
  672. of the program (such as c200,e) or else you will have to 
  673. specify the ending address and manually type a z command to 
  674. close the file. 
  675.  
  676.     sfilename.asm
  677.  
  678. A message will indicate that the file is opened.  Any
  679. subsequent a, b, or l command will have whatever is listed
  680. written to disk.  Encountering a 'e' control, or typing a z
  681. command will then close the .asm file.  The listing may
  682. be interrupted, and continued.  Since the l command types
  683. only 10 lines, use laddr,ffff to list thru the end of the
  684. assembly.
  685.  
  686. If this is the 'final' save of the .asm file, you will
  687. probably want to put an 'org' at the beginning of the
  688. output file, as well as generate equ instructions for
  689. any references outside of the program.  For example, a
  690. typical cp/m program will have references to:
  691.     bdos    at 5
  692.     fcb    at 5ch
  693.     tbuff    at 80h
  694.  
  695. the 'p' (for prologue) command generates the org, then
  696. scans the symbol table and generates equates:
  697.     BDOS    EQU    05H
  698.     FCB    EQU    05CH    (etc.)
  699.  
  700.  
  701. If you have a "e" control entry in your file, you can
  702. list as follows:  laddr,ffff - the listing will continue
  703. until the "e" control entry is found
  704.  
  705.  
  706. additional commands:
  707.  
  708. if you entered a label in the symbol table but now want
  709. to get rid of it:
  710.     k.symbol
  711.  
  712. note to rename a symbol, such as when you had a system-
  713. assigned lnnnn label but now want to make it meaningful:
  714.  
  715.     k.l0334
  716.     e334,.type
  717.  
  718. you could even:
  719.     e.l0334,.type
  720.     k.l0334
  721.  
  722. but that takes more typing.
  723.  
  724.  
  725.  
  726. here are some more commands:
  727.  
  728. ?        prints statistics on symbol and control table
  729.         usage, etc.
  730.  
  731. c        prints the entire control table
  732.  
  733. cnnnn        prints the control table starting
  734.         at address nnnn
  735.  
  736. ds        dumps the symbol table.  Interrupt it
  737.         by typing any key.
  738.  
  739. ds.symbol    starts dumping at the specified symbol,
  740.         or the nearest symbol.  thus "ds.f" starts
  741.         the dump at the first label starting
  742.         with the letter 'f'.
  743.  
  744. ....have fun, and let me know of any problems or
  745.     suggested improvements
  746.     ------------------------
  747.  
  748.         ZESOURCE
  749.     "Quick" command summary
  750.  
  751. Any address may be replaced by .symbol i.e. D.START
  752.  
  753. ;addr,comment        Enter a comment
  754. ;addr            Lists existing comment
  755. ;            Lists entire comments table
  756. ;addr,            Deletes existing comment
  757. A(see "L" for operands)    Attempt to find DB's
  758. B(see "L" for operands)    Build default sym tbl (Lxxxx)
  759. C            Dump ctl tbl
  760. Cnnnn            Dump ctl starting at nnnn
  761. Cnnnn,x            Define format from nnnn (B,E,I,S,W)
  762. Dxxxx            Dumps 80H from xxxx on
  763. Daaaa,bbbb        Dumps from aaaa thru bbbb
  764. D,bbbb            Dump thru bbbb
  765. D            Dump 80H more
  766. D=nn            nn= Hex dump size default.
  767. Ds            Dumps the symbol table.
  768. Ds.symbol        Sym dump starting at .symbol
  769. Ennnn,.symbol        Enter symbol into table, kill old
  770. Fnnnn,ssss        Find address nnnn starting at ssss
  771. F            Continue previous find command
  772. Fnnnn            Find nnnn
  773. K.symbol        Kill symbol from symbol table
  774. L            Lists 10 lines from prev pc
  775. Lssss,eeee        Lists from ssss to eeee
  776. L,eeee            Lists from current pc to eeee
  777. Lssss            Lists 10 lines at ssss
  778. L=nn            nn is hex list default # of lines
  779. O            Print current offset
  780. Onnnn            Establish new offset
  781. Pstart addr,end addr    Generate program prolog
  782. Q            Before any command suppresses
  783.             console output: QB100,200
  784. Rfilename.COM        Reads in at offset+100h
  785. Rfilename.CTL        Loads the ctl table
  786. Rfilename.SYM        Loads the sym file
  787. Rfilename.DOC        Loads the comments table 
  788. Rfilename.ALL        Loads the doc, sym, and ctl files
  789. Sfilename.ASM        Save .ASM file.  Write w/L, Z to end
  790. Sfilename.CTL        Saves the CTL table
  791. Sfilename.SYM        Saves the sym file
  792. Sfilename.DOC        Saves the comments table
  793. Sfilename.ALL        Saves the doc, sym, and ctl files
  794. Unnnn            Use nnnn for comments table
  795. X            Purge all symbols and control
  796. Z            Write eof to .ASM file
  797. ?            Prints statistics (sym, ctl, comments)
  798.