home *** CD-ROM | disk | FTP | other *** search
-
-
- Dissassembly of a .COM file using DASM.COM
-
-
-
- Everybody needs or wants to disassemble a program some time, usually
- just to modify a small section of it for an application that the program
- was not originally intended. At Micro Cornucopia we get a lot of programs
- with no source code that "almost" work on the Kaypro. This is where DASM
- is invaluable. ZZSOURCE (on user disk K2) was a good program but hard to
- use the first time. This often caused a block for some people that they
- could never get past. DASM is a re-write of ZZSOURCE that makes it much
- easier to use, the first time and again and again. The built in help
- screen in itself is a major improvement but there is more to this version
- than that.
-
- This documentation is designed for the beginning disassembler though for
- most it is all they need know. A good text editor can do wonders for a
- file that is only partially disassembled with DASM and this is how I
- usually use DASM.
-
- For an example, lets disassemble the file on this disk CRC.COM. Enter
- DASM by entering:
- DASM<carriage return>
-
- DASM will sign on and give you a prompt (*). It also will tell you how
- to get the help screen and stats. The help screen is a list of all the
- commands that DASM will except. Display it by entering:
-
- H<carriage return>
-
- The first thing we need to do is read the file we want to disassemble
- into memory. Since DASM sets up an offset automatically we only need to
- enter:
-
- RCRC.COM
-
- DASM will tell us where the file resides:
-
- Last Block Read into Memory at 5800
- Last Block Ends at Relative 0C00
-
- The second address is of the most interest to us. The file actually resides
- in high memory but the disassembler makes it seem as if it is at 100H.
- It also makes it seem as if it ends at 0C00. We only need to worry about
- the relative addresses and DASM will do the offset for us. If we enter:
-
- L100
-
- DASM will disassemble the first 20 lines of the program CRC.COM as if it
- were at 100H (where .COM files are loaded by CP/M).
-
- The next thing to do is to define the end of the program. It is unlikely
- that a program will fill an entire block to the last byte. We can find the
- actual end by dumping memory (relative) until we find what seems to be
- the end of the program. To do this enter:
-
- DB80
-
- This dumps memory up to BFFH. It appears that CRC.COM ends a little before
- 0C00 but not to much farther before. We can end the program at BFFH just
- to be sure we have it all. The trailing 0's will disassemble as NOP's which
- won't bother us much anyway.
-
- Now we can enter the end of file mark by entering:
-
- CBFF,E
-
- Where BFF is the HEX address of the end of the program that we found. Now
- DASM will stop when it reaches this point because we told it that the
- program ends here.
-
- The next thing to do is to look for DB's in the program. DASM will do this
- for us. Enter:
-
- A100,FFF
-
- Notice that we entered a range that exceeds the length of our program but
- that DASM will stop at BFF since we told it that this is the end of the
- program. Take a look at the program with the L command to see what DASM has
- done.
-
- Now we should build labels. Enter:
-
- B100,FFF
-
- DASM will create labels starting with L and ending with a hex address. Then
- it places these labels in the jump and move instructions etc. Examine our
- program with the L command to see what it looks like now.
-
- We almost have a workable source file out of the .COM file. It is time to
- get it out to disk. To begin this process enter:
-
- SCRC.ASM
-
- DASM will remind you that the program needs an end but we have already done
- that. We will want equates for the labels that DASM created. To get these
- and an origin statement at the beginning of our .ASM file enter:
-
- P100,FFF
-
- Then write the rest of the file to disk by entering:
-
- L100,FFF
-
- Then exit DASM by entering a ^C.
-
- We will still need to fiddle with the file to get it to assemble again.
- If you are using the M80 assembler you will need to add ASEG and .Z80
- lines to the beginning of the program and change the extent to .MAC .
- The CROWECPM assembler will require that you change the DB's to DEFM's
- and change the extent to .Z80 .
-
- Then try to assemble it. There will probably be a few errors since DASM
- does not always find all the labels when building an equate table. Add
- these in to the source file with a text editor. Since DASM names the labels
- by their address with an L in front of it this is easily done. For example
- an equate for L0100 would look like this:
-
- L0100 EQU 0100H
-
- Once you have found the undefined labels the program should reassemble.
- You can verify that the .COM files are identical with CRC.COM or COMPARE.COM
- ( on disks K2 and K16 ).
-
- For more information on DASM see DASM.DOC.
-
-