THE ELEMENTS OF AN ASSEMBLY LANGUAGE STATEMENT
In a standard Assembly language statement, there are four fields. The fields
are normally separated by a space or a tab character. In many statements, there
are fields missing. They can be generally represented and studied from the following
example:
|
Label
|
Operator
|
Data
|
Comment
|
|
Field
|
Field
|
Field
|
Field
|
;if AH is not zero, this routine adds 30H to AL return
Add_AL_30 PROC near
cmp ah,0 ;compare AH to zero
jnz add_al_0 ;jump if not zero, else
add al,30H ;this statement adds 30 to AL
add_al_0:
;return to calleru
ret
Many program listings start with comments by the program that usually explain the purpose of the code along with additional information. The comment field always starts with the semicolon (;). If the other three fields are empty, then the comment field can begin at the start of a line. The comment field can never come before any other fields on the line. If the comment is more than one line long, then you need a new semicolon at the start of the comment on each line. All comments are optional and are usually put there by the programmer to keep track of program logic.
The label field when used always comes before any other
field on a line. This field is used to define names that the programmer creates
to reference that location in the program. Here are three ways to define a
label:
1. terminating
the label with the colon character (:)
2. using the PROC
statement if the label is for a coding procedure
3. using the
LABEL statement if the label is for a data structure or a data type (NEAR, FAR,
BYTE, WORD, DWORD, FWORD, PWORD, QWORD, TBYTE, DATAPRT, CODEPTR).
The operator field comes after the label field and before the data field.
This directs the compiler or the CPU to do something. This field is often
filled in with language mnemonics.
The data field comes after the operator field and before the comment field.
If the operator field requires variable data, then the data goes here. There
may be from none to many data variables or operands for an operation. When two
data variables are used with most common 8086 instructions, the first operand
is the destination and the second operand is the source.