|
Okay, we've tried to create a basic, do-nothing program in a number of ways. Before we get more into the details of exactly what a program actually is, differences between .COM and .EXE programs, etc., let's extend the program to actually get something to happen that we can see. Like before, I'll take you through several different ways. It's handy to be skilled with a few, just in case. Using DEBUGHere's the second program built with DEBUG:
This program is quite similar to the first one, except that we've inserted three other assembler instructions at the beginning and added one at the end. These are designed to actually display a message on the screen when the program runs. Try it out by running lesson02:
To appreciate exactly how this program works, you'll need to refer to the DOS reference manual mentioned on the previous page under Function 09h. I'll provide a copy of that page below. Using GRDBHere's the second program built with GRDB:
Again, the result will be a program in your directory called lesson02.com. Try and run it:
This is just the same as with DEBUG. Using MLNow, let's try building this second program using Microsoft's ML.EXE assembler and LINK.EXE linker:
Again, note that the last entered line shown above is really a control-Z and that it ends your input to the file. At this point, you now have an assembler source code file called lesson02.asm in your current file directory. Now, to assemble this file:
We'll come back later and discuss the differences between the assembler syntax and the debugger syntax. For now, it's enough to know that they produce similar programs. (If you are observant and look at the size of lesson02.com in the directory and compare the size with the same program generated using DEBUG or GRDB. The program generated using ML will be one byte longer. This is due to a "segment alignment" issue, but it doesn't result in any important difference.) What Does It All Mean?In this second example program, we make another function call to DOS, namely Function 09h. Let's look at the documentation from the technical reference for DOS programmers mentioned at the top of my PC Docs web page:
In .COM files, there's no need to perform the first two instructions mentioned in the example, here. This is because DS is already set to the right value. I hope you had good luck getting all this to work out on this second program!
Last updated: Wednesday, July 07, 2004 11:38
|