Low Level Programming


Machine Language Programming

Machine Language programs are programs written for their particular processor on a binary bit level. These programs control the processor's input/output ports, memory and peripherals that make up the computer. Machine language programs place the processor's instructions and arguments into memory where the processor can sequentially step through a program and follow the dictates these instructions demand.

DEBUG.EXE is a DOS program used to control the processor's registers and memory. Typically, it is used to create and edit executable programs with a specific format that are sent to the disk  with the extension of dot_COM  where they may be called and Run using DOS. It can also control the disk, other peripherals, input and output ports and anything that the computer is designed to interface with. Very powerful indeed.

There are a myriad of programs that are developed to perform these functions, but Debug provides a grass root way of examining the contents of programs and data blocks. It is invaluable for creating programs and editing them. One advantage of learning to use Debug is that it is free and already comes with Windows. Another is that it clearly demonstrates the evolution of Personal Computer developement. This presentation will demonstrate some of the more useful features of Debug and how they are used.




Using DEBUG.EXE

This presentation is intended to be a simple over-view of DEBUG.EXE used in WINDOWS using the Intel processor. I call it a low level program because it performs on a binary bit level. Several functions are available for convenience, not generally found in any single application program. It was designed to provide all of the software tools necessary to maintain the entire Disk Operating System.

Here are some of the features:
1. The ability to display and change the processor registers.
2. Create and display programs, either in machine or assemply format
3. Run programs in real time and with break points and trace mode.
4. Load programs and data from disk and save it back to the disk.
5. Disasemble programs into assembly language display.
6. Assemble the programs directly into machine code.
7. Save executables to disk as .COM files that can be run from Windows. 


And much more. A search on the web will pull up many applications for DEBUG.


Getting Started

This presentation is undoubtedly being viewed in Windows. Debug existed long before Windows. The computer was booted up with a short bootstrap machine language program that loaded the Master Boot Record from the floppy disk into memory, providing operations on the floppy disk. This code is the Disk Operating System, or DOS. An interpreter permitted an operator to interface with DOS from the keyboard with an interpreter named COMMAND.COM. This permitted running  Applications under program control. Debug further permitted creating and editing these programs. GWBasic and Basica were high level programs that provided program control of the computer. One of the applications developed was the Windows program. 

Prior to XP Windows was just another application program run under DOS. Windows XP changed all that because Windows XP is a system in itself and Debug and other DOS programss were emulated by the Windows XP. There are some differences in the way Windows emulated DOS than when running Native Dos from a DOS boot sequence. This is covered more fully in another section. For now, it should be said that emulated Dos has limitations that the Native Dos doesn't have. Occasional mention of these differences will be mentioned during this presentation.


"Why is all this background necessary"?, asks the inquisitive reader.
In response, its is because we are about to partake in an adventur into the computer and go where most computer operators have not gone before.
Things can be done with this level of program control that are simply not available to most computer operators.
A good basic understanding of the function of the root programs is absolutely necessary for using them.


                 Having said that, lets get started:
first: click start- RUN- type in Debug and click on OK.
next: type in the question mark and press the enter key.
last: type in the character Q and press the enter key.



The first step called DEBUG.EXE and executed it. It opened in a Window called the Console. Type ALT ENTER to display in the old fashioned DOS display. Another ALT ENTER will return to the console display. The minus sign prompt will invite a character to be entered under Debug.

The next step uses the traditional interogative, ? to provide help. Debug will provide a real time display of the commands used under DEBUG. Look down the list and find the Q character that will quit the session and return to caller.  Prior to quitting Debug; however, the other Debug functions are available to the operator.

The last step terminates the DEBUG program. In this demonstration, control will be returned to the Windows program. But in the original DOS controled system, control would have been returned to the Command line Interpreter named Command.Com. Normally DEBUG operations would be executed from the KEYBOARD. But our demonstrations will use some Batch files to clearify the operations used during a DEBUG session. Batch files have the advantage of reducing typos.



Here are some exercises that will further demonstrate the use of Debug. The first time through, they should be taken in the order presented.



Exersizes

Make a print-out of the Debug display
Print out the DEBUG display.. using ? and Q with the MARK and COPY functions.

The H function (sum and difference)
Display the sum and difference between two hex numbers from 0 to FFFF.

The R function (registers)
Display and edit the contents of the processor's internal registers.

Batching Debug functions
Commit debug instructions to batch files for convenience and dependability.

The A, N, & W functions (assemble)
Assemble a COM program, name it and save it to the disk

The U, D, E, L, & G functions (editing)
Test and Edit a COM program, and re-save it to the disk

The I and O functions (Hard I/O)
Create a program that talks to the Computer's internal Speaker