Document 1115
SID and DEBUG Script
04/13/92
BK

                      SID AND THE DEBUG SCRIPT

        Below is a generic listing of a typical DEBUG script that one
can often find on BBS's or in magazines that will create some nice
little utility file using the command:

        DEBUG < filename.ext

         What follows are the steps that one would use to adjust a
script so that DR DOS 6.0's SID utility will produce the same file
using the command:

        SID < filename.ext

        These scripts will usually follow a pattern. They will first
establish the name of the file. SID does not require the name of the file
until it is actually saved at the end. Then they will use the 'A' command
to start assembling the instruction. DEBUG defaults to an offset of 100.
In SID, one specifies that assembly should begin at offset 100 by the
A100 command. Then the instructions for the utility itself are listed.
These instructions should be identical under both DEBUG and SID. Finaly,
DEBUG is told how many bytes of information to save using the RCX command.

        When one saves the file using SID, one specifies what the
beginning and ending addresses should be. The beginning address is 100.
The ending address is 100 + the number of bytes to be saved - 1 (In
the example below, the ending address is represented by the word END).
Since the arithmetic is in hexadecimal values, one may want to use the
H command in SID to do the calculations (See the HEX NOTE below). The
last command is to quit. It is the same under both utilities.

GENERIC SCRIPT

DEBUG SCRIPT    SID SCRIPT              COMMENTS
-----------------------------------------------------------------------
N filename.ext  (not required)         -SID uses file name when it is saved.
A               A100        ---------+ -Begin assembling instructions.
(instructions   (instructions        | -Use the original commands.
go              go                   |
here)           here)                |
                                     |
<CR>            <CR>                 | -<CR> to exit assembling
RCX             (not required)       | -DEBUG is preparing to save y bytes
y               (not required)       |   of data. +----------------+
W               Wfilename.ext,100,END| -SID writes|from offset 100 to END
                                     |    ( 100 + y - 1 = END )
                                     |       |
                                     +-------+
Q               Q                       -And Quit.


Below is an example of a script that will build BEEP.COM, a program
that simply beeps the speaker once. Notice again that the arithmetic is in
hexadecimal. (If that is something with which you are unfamilure, see the
HEX NOTE at the end of this example.)


DEBUG SCRIPT    SID SCRIPT      COMMENTS
-----------------------------------------------------------------------
N BEEP.COM      (not required)          SID saves file name at end
A               A100        --------+   Begin assembling instructions
MOV AH,2        MOV AH,2            |   Use the original commands
MOV DL,07       MOV DL,07           |
INT 21          INT 21              |
MOV AH,4C       MOV AH,4C           |
INT 21          INT 21              |
<CR>            <CR>                |   <CR> to exit assembling
RCX             (not required)      |   DEBUG is preparing to save 10 (A Hex)
A               (not required)      |   of data.  +----------------+
W               WKEYD.COM,100,109   |   SID writes|from offset 100 to 109
Q               Q                   |     ( 100 + A - 1 = 109 )
                                    |        |
                                    +--------+


HEX NOTE:       SID can do the hex math for you. In the above example,
                to do the first addition ( 100 + A ), load SID and type

                H100 A

                SID will respond:

                + 010A   - 00F6   * 00000A00   / 0019 (0006)

                The first value, 010A, is the sum. Use that value in the
                next command:

                H10A 1

                SID will respond:

                + 010B   - 0109   * 0000010A   / 010A (0000)

                The second value, 0109, is the END value you want to use.
