Assembly language introduction, Figure 6, Example assembly language statement – Zilog Z16F2810 User Manual
Page 37: Loop: sub r5, r7 ;subtract

UM018809-0611
Assembly Language Introduction
ZNEO
®
CPU Core
User Manual
21
Assembly Language Introduction
Assembly language uses mnemonic symbols to represent instruction opcodes. Operands
such as register names and immediate data is represented symbolically, numerically, as
expressions, or by labels defined elsewhere in the program.
Figure 6 displays a typical assembly language statement.
An assembly statement can include one or more the following elements:
Label.
An optional text string used to refer to this statement elsewhere in the program. A
string is considered a label definition if it is not an assembler keyword, and it either begins
a line or is followed by a colon. The label definition identifies the address of the instruc-
tion that follows it.
Instruction Mnemonic.
The mnemonic code for the desired operation.
Destination Operand.
The destination location for the operation. In assembly, the desti-
nation operand is always first if both operands are specified.
Source Operand.
The source location or immediate data for the operation.
Comment.
An optional text field ignored by the assembler. Comments are used to
describe the flow of a program so it is easier to understand and maintain later.
Instead of instruction mnemonics, some assembly statements contain assembler directives
(also called pseudo-ops), which are not translated into object code. Directives are used to
select memory segments, allocate storage in memory, define macros, and control the
assembly process.
Example Assembly Language Source
An assembly language program is written in a plain text file called as source file, which
contains a sequence of assembly language statements and directives.
Below is an example of an assembly source file:
SEGMENT NEAR_TEXT
; Directive to place the following statements
Figure 6. Example Assembly Language Statement
LOOP:
SUB
R5, R7
;Subtract
Label
(Optional)
Instruction
Mnemonic
Destination
Operand
Source
Operand
Comment
(Optional)