!pr1
Using EXEC Files with Rak-Ware's DISASM...........Bob Kovacs

[ Bob is the author of DISASM, owner of Rak-Ware ]

I recently received a phone call from Alan Lloyd who had just purchased DISASM.  He wanted to use it to disassemble the Autostart ROM so he could customize the code for a particular application.  He was frustrated by the limited editing capabilities of DISASM which makes you start all over again if you don't catch your mistake before hitting RETURN.  Since he had to enter the starting and ending addresses of over a dozen data tables, he began searching for an easier (and less painful) way of entering the data.  He decided to try using an EXEC file with DISASM, and it worked!  Well, sort of.

I thought about the problems he ran into, and found out some interesting things about the S-C Macro Assembler along the way.  It turns out that with the help of a small patch to DISASM that it is possible to run the entire program via "remote control" using an EXEC file.

The first step is to create the TEXT file that will later be EXECed.  You can do this in a word processor, if your word processor makes ordinary DOS text files.  Or you can write an Applesoft program to help you build an array of addresses and the proper answers to the various prompts in DISASM, and then write a complete EXEC file.  I decided to use the S-C Macro Assembler, because you can use the TEXT <filename> command to write a text file.  You can have the assembler in the language card, DISASM at $800, the thing to be disassembled wherever you want, and pop back and forth fast as lightning.

Just enter each line of "source" as if you were responding to the questions put to you be DISASM.  You can even include lines to turn on display of DOS commands and I/O (MONIOC), and the BLOADing of DISASM and NAMETABLE.

The S-C Macro Assembler does make one thing difficult.  Some of the questions asked by DISASM require a null line (a RETURN all by itself), and S-C makes it very hard to get a null line.  The first of these is used to terminate the entry of data table addresses.  (Alan was satisfied to have his EXEC file stop here and take over manually.)

Normally, S-C does not let you enter totally empty lines.  Typing a line number without any following text is one of the ways to DELETE a line, just as in both BASIC's.  After a little experimenting I discovered a trick to fool the S-C input routine.  I still don't get a totally empty line, but I can put extra RETURNs into an existing line.  Here's how:

       1.  Type in the text of all the non-null lines
           you want in your EXEC file.

       2.  Use the EDIT command to insert extra RETURNs
           in the proper places:  move the cursor to
           the character position desired, and type
           ctrl-O followed by RETURN to insert each
           extra RETURN.  Each extra RETURN will show
           up as an inverse "M" as you are editing.
           Then type one more RETURN to exit the EDIT mode.

The next problem I ran into was the Y/N responses for the "Full Cross-Reference" and "Generate Text File" questions.  DISASM looks directly at the keyboard for those two responses, so it is blind to any EXEC file inputs.  A five byte patch fixes all that, so you can use EXEC file as well as keyboard inputs.  Just change the code starting at location $C5A from AD 00 C0 10 FB to 20 18 FD 09 80.

The following arbitrary example illustrates how an EXEC file might look when typed into the S-C assembler (extra RETURNs are indicated by <M>):

!lm+5
1000 MONIOC
1010 BLOAD DISASM
1020 BLOAD NAMETABLE
1030 $800G          (Use call 2048 to EXEC from BASIC)
1040 2              (select S-C Assembler format)
1050 F800           (starting physical address)
1060 F9B9           (ending physical address)
1070 F800           (starting execution address)
1080 F8CD           (table #1 start)
1090 F8CF           (table #1 end)
1100 3              (table #1 format)
1110 F962           (table #2 start)
1120 F9A5           (table #2 end)
1130 5              (table #2 format)
1140 F9A6           (table #3)
1150 F9B3
1160 8
1170 F9B4           (table #4)
1180 F9B9
1190 6
1200 <M>2000        (end of tables, and NAMETABLE address)
1210 0              (no printer output)
1220 <M>NYDEMO      (RETURN for no single cross reference,
                     N for no full cross reference,
                     Y for creating a textfile named DEMO)
!lm-5

(Of course, you realize that the explanatory comments in parentheses are not supposed to be typed.)  I advise you to SAVE the lines on a file as S-C source code, using the SAVE <filename> command.  This will become the copy you re-LOAD when you want to make changes.  Then use the TEXT <filename> command to write out the EXEC file.  Finally, EXEC <filename> to run the disassembly!

When EXECing, the table addresses are entered at a blinding speed that is almost imposssible to follow.  If your text file has an error in it such that it does not conform to the DISASM input syntax, then things can go very wrong very fast.  For those of you who would rather not see things move along quite so fast, I suggest adding a small patch to the COUT vector which provides a short delay.  The following program works fine:

     $300:48       PHA
          A9 80    LDA #$80
          20 A8 FC JSR $FCA8
          68       PLA
          4C F0 FD JMP $FDF0

You can hook this into DOS from the assembler by typing "$36:00 03 N 3EAG".  Then change line 1030 above to $812G (or CALL 2048+18 for EXEC from BASIC) to bypass DISASM's effort to setup the default DOS vectors.

Or you can even include all this stuff along with the original EXEC file.  Either way, it is easier to use DISASM with an EXEC file when there are lots of data tables to be entered and you have fumble-fingers at the keyboard.

From now on, DISASM will be shipped with the five-byte patch indicated above already installed, and with two sample EXEC files designed to be EXECed from BASIC.
