Hardware Reference
In-Depth Information
names for instructions and registers is called an assembly language program .To
run such a program, it is first necessary to translate it into the binary numbers that
the CPU actually understands. The program that converts an assembly language
program into binary numbers is the assembler . The output of the assembler is
called an object file . Many programs make calls to subroutines that have been pre-
viously assembled and stored in libraries. To run these programs, the newly-
assembled object file and the library subroutines it uses (also object files) must be
combined into a single executable binary file by another program called a linker .
Only when the linker has built the executable binary file from one or more object
files is the translation fully completed. The operating system can then read the
executable binary file into memory and execute it.
The first task of the assembler is to build a symbol table , which is used to map
the names of symbolic constants and labels directly to the binary numbers that they
represent. Constants that are directly defined in the program can be put in the sym-
bol table without any processing. This work is done on pass one.
Labels represent addresses whose values are not immediately obvious. To
compute their values, the assembler scans the program line by line in what is called
the first pass . During this pass, it keeps track of a location counter usually indi-
cated by the symbol ''.'', pronounced dot . For every instruction and memory reser-
vation that is found in this pass, the location counter is increased by the size of the
memory necessary to contain the scanned item. Thus, if the first two instructions
are of size 2 and 3 bytes, respectively, then a label on the third instruction will have
numerical value 5. For example, if this code fragment is at the start of a program,
the value of L will be 5.
MOV AX,6
MOV BX,500
L:
At the start of the second pass , the numerical value of every symbol is known.
Since the numerical values of the instruction mnemonics are constants, code gen-
eration can now begin. One at a time, instructions are read again and their binary
values are written into the object file. When the last instruction has been assem-
bled, the object file is complete.
C.5.2 The ACK-Based Assembler, as88
This section describes the details of the assembler/linker as88 , which is pro-
vided on the CD-ROM and website and which works with the tracer. This assem-
bler is Amsterdam Compiler Kit (ACK) and is patterned after UNIX assemblers
rather than MS-DOS or Windows assemblers. The comment symbol in this assem-
bler is the exclamation mark (!). Anything following an exclamation mark until
the end of the line is a comment and does not affect the object file produced. In the
same way, empty lines are allowed, but ignored.
 
 
Search WWH ::




Custom Search