Home Up Early Material Text Errata Endian Wars Assembler DEBUG Basics
2003-09-23 11:46

Trace: CALL
Trace: INT
Trace: small prog
Control Structure
Executable Formats

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 link.

This page contains the following sections:

Understanding PUSH, POP, CALL, and INT
Program Control Flow
Sample Programs and Program Style
Program Debugging and Tracing

Understanding PUSH, POP, CALL, and INT

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 bottom of the single segment, typically starting at FFFEh.

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:
DEBUG Input Annotated DEBUG Output
push_pop.txt  push_pop_out.txt
call_push.txt  call_push_out.txt
int_push.txt  int_push_out.txt

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 Intel instructions.

Program Control Flow

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.

Sample Programs and Program Style

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 well-written!)

Program Debugging and Tracing

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 debug them.

You can see an example of tracing a very small assembler program here.

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.


Web Author: Ian! D. Allen      Updated: 2003-09-23 11:46

Internet Free Zone Level 1 logo Support free and non-commercial Internet.

Any Browser logo This site works best in Any Browser, a campaign for non-specific WWW.

Creative Commons License logo This work is licensed under a Creative Commons License.