Hardware Reference
In-Depth Information
The Microsoft editor is extremely powerful. It provides the usual cut
and paste , and search and replace facilities together with macros which
can be invoked from a single keystroke. Furthermore, to reduce the overall
edit/assemble cycle time, it is possible to assemble a program from within the
editor, view, and correct any errors that may have occurred, then re-assemble.
Multiple source files can easily be handled and a split-screen windowing facility
can be used to examine and edit different parts of the same file simultaneously.
When preparing source text using an editor, it is important to bear in mind the
requirements of the assembler concerning the format of source code statements.
In the case of most x86 assemblers (and Microsoft's MASM in particular), each
line of source code is divided into four fields, as shown in the example below:
Symbol
Operation
Argument
Comments
maxcount DB
16
; initialize maximum count
The first entry in the line of code is known as a symbol. The symbols used in
a program are subject to certain constraints imposed by the assembler but are
chosen by the individual programmer. Labels are a particular form of symbol
which are referred to by one, or more, statements within a program. Labels are
used to mark the entry point to the start of a particular section of code or the
point at which a branch or loop is to be directed. During the assembly process,
labels (wherever they appear in the program) are replaced by addresses.
Entries in the operation field may comprise an operation code (opcode) ,a
pseudo-operation code (pseudo-op) ,an expression , or the name of a macro.
Operation codes are those recognized by the microprocessor as part of its
instruction set (e.g. MOV, ADD, JMP , etc.) whereas pseudo-ops are directives
which are recognized by the assembler and are used to control some aspect
of the assembly process. Typical pseudo-ops are DB (define byte), DW (define
word), ORG (origin or program start address), and INCLUDE . The last-named
directive instructs the assembler to search a named macro library file and to
expand macro definitions using this library.
The argument field may contain constants or expressions, such as 0DH, 42,
64*32, 512/16, 'A', 'z'-'A' , or the operands required by microprocessor
operation codes (represented by numbers, characters, and symbols, which are
extended opcodes).
The comment field contains a line of text, added by the programmer, which
is designed to clarify the action of the statement within the program as a whole
(see Chapter 4).
In the example shown previously, the variable maxcount has been declared in
the symbol column. The operation field contains a pseudo-op (assembler direct-
ive) which instructs the assembler to reserve a byte of storage and initialize its
value to 16. Thereafter, any references to maxcount will take the value 16 (at
least until the value is next modified by the program). The programmer has
added a comment (following the obligatory semicolon) which reminds him or
her that maxcount is the symbol used to hold the current maximum value of the
counter.
Not all source code lines involve entries in all four fields, as in the next
example:
Symbol
Operation
Argument
Comments
Mov
AL,maxcount ; get maximum count
Search WWH ::




Custom Search