Assemble,
Name,
and
Write a
COM file to disk
Debug
can be used to create an executable program in machine language.
Machine language programs
are fast and take up relatively little space on the disk. Debug
creates COM
file using the (assembler) function. Com executables
were originally intended to be run under DOS. They can be
run, like EXE
files under Windows as well.
We will create this COM program to
run under DOS
using the Debug program. We will also create this executable machine
language program using a Batch stream to better illustrate the process.
We will finally call the DOS Prompt and execute the program to display
a single character in the DOS console display.
Two additional batch files will be created on the Floppy Disk. Caller.bat is a
loader file that is called under passing on the name of the text file
with the DOS Debug
commands in the calling sequence. This permits Caller.bat to be
used to batch inputs from any number of text files, by name. The text
file with the Debug
commands is named Assemble.txt.
The rusult of the operation will create an executable file named Assemble.Com
that can be run under DOS.
Caller.Bat
Create a file on the Floppy Disk named Caller.Bat
with the following contents.
a:debug.exe < a:%1
pause
The Caller.bat
program is a simple two line set of instructions the same as did the Batching.Bat
file in the Batch example. The calling sequence was to type Batching under
the DOS
prompt to run the process. The name of the text file was given the the
batch stream of Batching.Bat.
Caller.Bat replaces the file name with the %1 directive
which permits us to name the text file to be input in the calling
sequence. The calling sequence with Caller.Bat, at
the DOS
Prompt is Caller
filename.
The pause
directive halts the Batch stream
long
enough to view the result of the process before terminating the
Batch process.
Assemble.txt
Create a text file on the Floppy Disk with the following Debug
instructions:
a
mov ax, 0200
mov dx, 0041
int 21
int 20
n A:ASSEMBLE.COM
rcx
000A
w
q
The first five lines assemble our program
into memory. The a calles Debug's
assembler function. The number 02
is moved into the AX
register to call the
interupt 21's second function to output a single character to
the display. 41
is the ascii code for the character A and is moved
into the DX
register for interupt 21. Interupt
21 is executed, using the data in the AX and DX registers,
outputing the character A to the
display. Finally interupt
20 exits the program and returns control to the calling program,
DOS. The
blank line is a character return and is necessary to terminate the
Debug's assemble function.
Debugs N
function names the output file. RCX
inserts the number of bytes to be written to disk into the CX
register. Again the blank line is necessary to terminate Debug's Register
function. The W
outputs the program in memory to the Flippy Disk and finally the q
instruction terminates Debug and
returns program control back to the DOS prompt.
Assembling the Com file
with a Batch Stream
After having copied the two files to the Floppy Disk, the assembly
sequence is run with the DOS Prompt
Interpreter.
Double click on the Command.Com icon
in the Floppy Drive to run the DOS Prompt
Interpreter.
On the DOS Prompt, enter Caller
interupt.txt
and press ENTER.
This is the display that will be in the DOS prompt console window after
executing Caller.BAT......
A:\>a:debug.exe
0<a:assemble.bat
-a
0AF8:0100 mov ax, 0200
0AF8:0103 mov dx, 0041
0AF8:0106 int 21
0AF8:0108 int 20
0AF8:010A
-n A:ASSEMBLE.COM
-rcx
CX 0000
:000A
-
-w
Writing 0000A bytes
-q
A:\>pause
Press any key to continue . . .
Test the newly created
Com file
Testing the new file name
Assemble.Com is done in the DOS Prompt mode.
Double click on the Command.Com icon in the Floppy Disk.
Type assemble and Enter.
The character A will be displayed and another prompt will be presented.
This is all that is necessary to determine that the newly created
executable has been assembled and works.
Assemble.com can be run under Windows by calling it with a double click
or with the START RUN feature; however, it will not be displayed long
enough in the DOS Prompt console for us to see that the character has
actually been posted to the display.
This conclued the Assembly function example. There are many examples of
DOS programs on the web and also in the DOS section of this tutorial.
y