Introduction to Pentium Assembly Language
Goals: This laboratory provides an introduction to Pentium assembly
language.
References: The following manuals may provide useful additional
commentary for the elements of Pentium assembly langauge.
-
Intel's Pentium III Manuals:
These provide the definitive word on the Pentium and its instructions.
While these are technically complete and good for reference, they may nor
may not be easy reading for beginning assembly-language programmers.
Note: The order of instructions operands for Intel assembly is reversed
from the order used for AT&T Pentium Assembly -- as used by the gcc
compiler and as assembler!
-
IA-32 IntelŪ Architecture Software
Developer's Manual, Volume 1: Basic Architecture (pdf format: 4,005K
bytes, 422 pages)
-
IA-32 IntelŪ Architecture Software
Developer's Manual, Volume 2: Instruction Set Reference (pdf format:
6,593 Kbytes, 964 pages)
-
IA-32 IntelŪ Architecture Software
Developer's Manual, Volume 3: System Programming Guide (pdf format:
6,269 Kbytes, 696 pages)
-
IntelŪ PentiumŪ 4 and IntelŪ XeonTM
Processor Optimization (pdf format: 1,505 Kbytes, 333 pages)
(These are large files, so will take some time to load. While one copy has
been downloaded and is available locally through the above links,
please do not make additional copies for own account.)
-
Dominique Thiebau, The Art of
Assembly Language Programming,
http://cs.smith.edu/~thiebaut/ArtOfAssembly/ArtofAsm.html .
This provides a nice description of the Pentium and its assembly language.
Terminology follows general Intel conventions, but may not contain specific
elements of GNU syntax.
-
Dean Elsner, Jay Fenlason, and friends,
Using
as : The GNU Assembler,
http://www.gnu.org/manual/gas-2.9.1/html_node/as_toc.html
The basic assembler used on MathLAN's PC/Linux system.
Note that the syntax for the as assembler may not follow
normal Pentium conventions. The resulting code, however, is completely
equivalent.
It is strongly recommended that you include some of these references in
your list of Web bookmarks; pointers to the Instruction Set
Reference and to Thiebau's Web site are particularly encouraged.
Steps for this Lab:
-
Programs ~walker/assembly/prog1.c and
~walker/assembly/prog2.c each contain a linear search
procedure, written in C.
-
Copy these programs to your account.
-
Peruse, compile, and run the programs to check how they work.
-
Compare on any similarities or differences between these two programs:
-
How are constants declared?
-
Where are variables
item, elements and itemFound
declared?
-
How are data values read?
-
What parameters are used for procedures, and what is being passed
(e.g., addresses or values)?
-
How is the linear search performed?
-
How is the
found variable set?
-
Compile prog1 to assembly code, using the command:
gcc -S prog1.c
This command will produce an assembly language program, stored
in file prog1.s. Comment upon the general organization of
data for the portion of this assembly language program which comes from the
linearSearch procedure. In particular,
-
Where are variables
item, elements and itemFound
stored?
-
Indicate where the local variable index and the parameters
number, dataArray and found are stored.
-
Outline which registers are used for what information when.
-
How are values computed for the
done variable, and how is
done tested in the code generated from the while
and if statements.
-
Next compile prog2.c to assembly language.
Annotate the portion of this assembly language program which comes from the
linearSearch procedure. That is,
-
Where are variables
item, elements and itemFound
declared?
-
Indicate where all local variables and parameters are stored.
-
Identify all assembly language instructions and macros in the listing.
-
Outline which registers are used for what information when.
Work to be turned in:
-
Commentary for step 1c.
-
Steps 2a, 2b, 3a, and 3b may be accomplished either in a written discussion
or with an appropriate diagram of memory.
-
Steps 2c and 3d require a few sentences. While not required, a diagram of
registers and their usage may expedite the discussion.
-
Step 2d may be accomplished either in a written discussion or using a code
listing which you annotate.
-
Write the annotations for Step 3c on the assembled listing. The
annotations may be either long hand or typed as comments.
This document is available on the World Wide Web as
http://www.cs.grinnell.edu/~walker/courses/211.fa01/labs/as-assembler.html