Wednesday, 8 July 2015

usig MS DOS CMD

Image result for programming
Although every program in this tutorial has been a complete program, each one has also been
a very small program intended to teach you some principle of programming in C. It would do
you a disservice to leave you at that point without introducing you to a few larger programs to
illustrate how to put together the constructs you have learned to create a major program. This
chapter contains four programs of increasing complexity, each designed to take you into a higher
plateau of programming, and each designed to be useful to you in some way.
DOSEX was intended to illustrate how to make MS-DOS system calls and will teach you,
through self-study, how the system responds to the keyboard. DOSEX has been modified by
Tim Ward to use Applix 1616 system calls instead of MS-DOS calls.
WHATNEXT reads commands input on the command line and will aid you in setting up a
variable batch file, one that requests an operator input and responds to the input by branching
to a different part of the batch file.
LIST is the source code for the program you used to print out the C source files when you began
studying C with the aid of this tutorial. Finally we come to VC, the Visual Calculator, which
you should find to be a useful program even if you don’t study its source code. VC uses most
of the programming techniques we have studied in this course and a few that we never even
mentioned such as separately compiled subroutines.
We will take a look at the example programs one at a time but without a complete explanation
of any of them because you have been studying C for some time now and should be able to read
and understand most of these programs on your own. One other thing must be mentioned, these
programs use lots of nonstandard constructs and you will probably need to modify some of them
to get them to compile with your particular compiler. That will be left as an exercise for you.
dosexibm.c - The MS-DOS Example Program
The copy of MS-DOS that you received with your IBM-PC or compatible has many internal
MS-DOS calls that you can use as a programmer to control your peripheral devices and read
information or status from them. Some of the earlier IBM DOS manuals, MS-DOS 2.0 and
earlier, have these calls listed in the back of the manual along with how to use them. Most of
the manuals supplied with compatible computers make no mention of these calls even though
they are extremely useful. These calls can be accessed from nearly any programming language
but they do require some initial study to learn how to use them. This program is intended to aid
you in this study.
Display the program on your monitor or print it out for reference. It is merely a loop watching
for a keyboard input or a change in the time. If either happens, it reacts accordingly. In line
23, the function "kbhit()" returns a value of 1 if a key has been hit but not yet read from the
input buffer by the program. This is a nonstandard function and may require a name change for
your particular compiler. There will probably be several similar calls that will need changed
for your compiler in order to compile and run the programs in chapter 14.
Look at the function named "get_time" for an example of a MS-DOS call. An interrupt 21(hex)
is called after setting the AH register to 2C(hex) = 44(decimal). The time is returned in the CH,
CL, and DH registers. Refer to the MS-DOS call definitions in your copy of MS-DOS (if

No comments:

Post a Comment