home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / a / dasm15.lbr / DISASMBL.DZC / DISASMBL.DOC
Encoding:
Text File  |  1993-10-26  |  4.8 KB  |  129 lines

  1.  
  2.  
  3. Dissassembly of a .COM file using DASM.COM
  4.  
  5.  
  6.  
  7. Everybody needs or wants to disassemble a program some time, usually
  8. just to modify a small section of it for an application that the program
  9. was not originally intended. At Micro Cornucopia we get a lot of programs
  10. with no source code that "almost" work on the Kaypro. This is where DASM
  11. is invaluable. ZZSOURCE (on user disk K2) was a good program but hard to
  12. use the first time. This often caused a block for some people that they
  13. could never get past. DASM is a re-write of ZZSOURCE that makes it much
  14. easier to use, the first time and again and again. The built in help
  15. screen in itself is a major improvement but there is more to this version
  16. than that.
  17.  
  18. This documentation is designed for the beginning disassembler though for
  19. most it is all they need know. A good text editor can do wonders for a
  20. file that is only partially disassembled with DASM and this is how I
  21. usually use DASM.
  22.  
  23. For an example, lets disassemble the file on this disk CRC.COM. Enter
  24. DASM by entering:
  25.             DASM<carriage return>
  26.  
  27. DASM will sign on and give you a prompt (*). It also will tell you how
  28. to get the help screen and stats. The help screen is a list of all the
  29. commands that DASM will except. Display it by entering:
  30.  
  31.             H<carriage return>
  32.  
  33. The first thing we need to do is read the file we want to disassemble
  34. into memory. Since DASM sets up an offset automatically we only need to
  35. enter:
  36.  
  37.             RCRC.COM
  38.  
  39. DASM will tell us where the file resides:
  40.  
  41. Last Block Read into Memory at 5800
  42. Last Block Ends at Relative 0C00
  43.  
  44. The second address is of the most interest to us. The file actually resides
  45. in high memory but the disassembler makes it seem as if it is at 100H.
  46. It also makes it seem as if it ends at 0C00. We only need to worry about
  47. the relative addresses and DASM will do the offset for us. If we enter:
  48.  
  49.             L100
  50.  
  51. DASM will disassemble the first 20 lines of the program CRC.COM as if it
  52. were at 100H (where .COM files are loaded by CP/M).
  53.  
  54. The next thing to do is to define the end of the program. It is unlikely
  55. that a program will fill an entire block to the last byte. We can find the
  56. actual end by dumping memory (relative) until we find what seems to be
  57. the end of the program. To do this enter:
  58.  
  59.             DB80
  60.  
  61. This dumps memory up to BFFH. It appears that CRC.COM ends a little before
  62. 0C00 but not to much farther before. We can end the program at BFFH just
  63. to be sure we have it all. The trailing 0's will disassemble as NOP's which
  64. won't bother us much anyway.
  65.  
  66. Now we can enter the end of file mark by entering:
  67.  
  68.             CBFF,E
  69.  
  70. Where BFF is the HEX address of the end of the program that we found. Now
  71. DASM will stop when it reaches this point because we told it that the
  72. program ends here.
  73.  
  74. The next thing to do is to look for DB's in the program. DASM will do this
  75. for us. Enter:
  76.  
  77.             A100,FFF
  78.  
  79. Notice that we entered a range that exceeds the length of our program but
  80. that DASM will stop at BFF since we told it that this is the end of the
  81. program. Take a look at the program with the L command to see what DASM has
  82. done.
  83.  
  84. Now we should build labels. Enter:
  85.  
  86.             B100,FFF
  87.  
  88. DASM will create labels starting with L and ending with a hex address. Then
  89. it places these labels in the jump and move instructions etc. Examine our
  90. program with the L command to see what it looks like now.
  91.  
  92. We almost have a workable source file out of the .COM file. It is time to
  93. get it out to disk. To begin this process enter:
  94.  
  95.             SCRC.ASM
  96.  
  97. DASM will remind you that the program needs an end but we have already done
  98. that. We will want equates for the labels that DASM created. To get these
  99. and an origin statement at the beginning of our .ASM file enter:
  100.  
  101.             P100,FFF
  102.  
  103. Then write the rest of the file to disk by entering:
  104.  
  105.             L100,FFF
  106.  
  107. Then exit DASM by entering a ^C.
  108.  
  109. We will still need to fiddle with the file to get it to assemble again.
  110. If you are using the M80 assembler you will need to add ASEG and .Z80
  111. lines to the beginning of the program and change the extent to .MAC .
  112. The CROWECPM assembler will require that you change the DB's to DEFM's
  113. and change the extent to .Z80 .
  114.  
  115. Then try to assemble it. There will probably be a few errors since DASM
  116. does not always find all the labels when building an equate table. Add
  117. these in to the source file with a text editor. Since DASM names the labels
  118. by their address with an L in front of it this is easily done. For example
  119. an equate for L0100 would look like this:
  120.  
  121.             L0100    EQU    0100H
  122.  
  123. Once you have found the undefined labels the program should reassemble.
  124. You can verify that the .COM files are identical with CRC.COM or COMPARE.COM
  125. ( on disks K2 and K16 ).
  126.  
  127. For more information on DASM see DASM.DOC.
  128.    
  129.