Elements: Assembly Language Programming
An assembly language provides the following three basic facilities that simplify programming:
Mnemonic operation codes
The mnemonic operation codes for machine instructions (also called mnemonic opcodes) are easier to remember and use than numeric operation codes. Their use also enables the assembler to detect the use of invalid operation codes in a program.
A programmer can associate symbolic names with data or instructions and use these symbolic names as operands in assembly statements. Moreover, This facility frees the programmer from having to think of numeric addresses in a program. We use the term symbolic name only in formal contexts; elsewhere we simply say a name.
Data can be declared in a variety of notations, including the decimal notation. Also, It avoids the need to manually specify constants in representations that a computer can understand, for example, specify -5 as (11111011)2 in the two’s complement representation.
An assembly language statement has the following format:
[Label] <Opcode> <operand specification>[,<operand specification>..]
where the notation [..] indicates that the enclosed specification is optional. If a label is specified in a statement, it associated as a symbolic name with the memory word generated for the statement.
Moreover, If more than one memory word generated for a statement, the label would be associated with the first of these memory words.
<operand specification> has the following syntax:
<symbolic name> [± <displacement> ] [(<index register>)]
Thus, some possible operand forms as follows: The operand AREA refers to the memory word with which the name AREA associated.
- The operand AREA+5 refers to the memory word that is 5 words away from the word with the name AREA. Here ‘5’ the displacement or offset from AREA.
- The operand AREA(4) implies indexing the operand AREA with index register 4—that is, the operand address obtained by adding the contents of index register 4 to the address of AREA.
- The operand AREA+5 (4) is a combination of the previous two specifications.