Assembly Language Programming
This is a page of supplementary notes to help you learn to program in Intel
Assembler and debug your programs using DOS DEBUG. These pages are an
adjunct to the main
set of notes for this course written by Alan Pinck.
For some historical
background on how assembly language programming originated, and why it looks
the way it does, select this
This page contains the following sections:
The Stack is an essential part of assembly language programming. This
section starts with the simple Intel PUSH/POP instructions and then shows how
other assembly language instructions such as CALL and INT also use The Stack.
The PUSH, POP, CALL, and INT instructions all use the stack (the memory
area pointed at by SS:SP). In .COM format executables, the stack is at
the very top (high memory) of the single segment, typically starting at FFFEh,
and it grows downward in memory (toward zero).
The following DEBUG scripts and their
annotated output files show how the Intel CPU handles each type of instruction. Each of the input
text files was
run through DEBUG to produce the corresponding output file, to which
explanatory comments were added by hand:
C:\> debug <push_pop.txt >push_pop_out.txt
C:\> debug <call_push.txt >call_push_out.txt
C:\> debug <int_push.txt >int_push_out.txt
Read these annotated output files for examples and explanations of the workings of PUSH/POP,
CALL, and INT:
Homework, test, and exam questions typically show one of these types of
instructions and ask you to describe which registers and what memory is
affected after the instruction executes (see the Homework questions!).
Alan Pinck also supplies some additional exercises in tracing
Assembly language has no high-level control flow statements. To achieve the
same effect, you must use conditional branching. See the Control Structure page for details on how to turn
structured programming statements such as IF, WHILE, FOR, etc., into assembly language.
Copying and modifying well-written existing programs is a good way to learn
the style of assembly language programs. We have a small selection of sample
programs for you to examine in this course. (Not all are
Note that the comment style used in these programs is that of an
instructor teaching a student how to use assembly language. It is not
the style that you would use when writing programs in the real world, and it
it not the style you should use when submitting your projects.
If you can't figure out what your program is doing, you can debug it
one-line-at-a-time using the DOS DEBUG command. The DOS DEBUG command lets you single-step through your programs to
You can see an example of tracing a very small assembler program
For more information on using
DEBUG, see the Using DOS DEBUG page.
Executable File Formats
Here is a summary of the differences
between MSDOS .COM executables and .EXE executables.