Open main menu

Wikibooks β

Computer Programming/DOS Programming

< Computer Programming


About the platformEdit

MS-DOS was Microsoft's first Operating System. It was built upon QDOS (Quick and Dirty Operating System), which was based on Gary Kildall's CP/M. The original MS-DOS was simplistic and very difficult to use for the untrained. As time progressed, the interface remained essentially the same (keyboard on a text console), however it had some significant usability features (e.g. DOSKey) implemented as well. Microsoft retained the crown of most used DOS until it usurped its own OS with Windows, however there were other non Microsoft versions of DOS as well. DR-DOS was the primary non MS-DOS and did fairly well until Windows 95 arrived. Afterwards, most people abandoned the non-GUI DOS system. A few diehards survived, however, and some have produced a version of DOS written under an Open Source license known as FreeDOS. Although abandoned by its "creator", DOS is still a stable and viable operating system, although it has been overshadowed by Windows and the most popular open source operating system, Linux.

DOS is still occasionally used on boot disks, so system recovery software may sometimes be written for DOS.

The most popular languages for use on the DOS platform, besides DOS batch files and Intel x86 Assembly Language, are C and BASIC.

See QEMU/FreeDOS and A Neutral Look at Operating Systems/DOS for more information about FreeDOS.

C/C++ CompilersEdit

The main compiler for 32-bit DOS is DJGPP ( ). Nevertheless, 16 bit programs make up a substantial amount of the pre-Windows 95 program set, and so you may need to find a 16 bit compiler if you want to program on extremely old computers.

For the most part however, one can just use a 32 bit DOS extender, such as CWSDPMI.

Batch filesEdit

DOS allows the use of batch files, which are a collection or "batch" of DOS prompt commands stored in a file. When a user types in the filename (with or without the extension) of a batch file, DOS will perform each command listed in the .bat file, then return control to DOS.

Assembly LanguageEdit

DOS comes with a low-level debugger called DEBUG. This allows debugging of an executable program which it loads into memory along with DEBUG. This is done by running DEBUG program at the DOS prompt, where program is the name of your program. DEBUG will work with .com and .exe executables. You must include the file extension in the filename when you call it using DEBUG. DEBUG does not work with .bat files.

DEBUG can also be run without a file to view CPU register contents, memory, and to assemble machine instructions directly into memory. A brief walkthrough of how to run DEBUG to view and change memory and registers, as well as assemble and run some basic machine instructions can be viewed here.