
4-2
Assembler
bnz start
add r0, r1
bnz Start:
!“start” is a label reference
!“l(fā)oop” is a label
! Illegal reference (extra colon)
! Illegal label (missing colon)
loop:
End
Symbols beginning with ‘
L
’ are locally resolved, and are therefore not
visible to the linker or to other modules.
Assembler statements can be assembler directives or assembly
language instructions. Assembler directives start with a period (‘.’).
Comments start with an exclamation mark (
!
) and continue until the end
of the line. The symbol ‘
#
’ at the beginning of the line indicates that it is
a comment.
Note that files with the
.S
extension can be assembled using
sdcc
, which
causes the C preprocessor to run before the assembler. This enables
users to use C-style comments and
#defines
in their assembly code.
However using a
-g
option will not cause any debug symbol generation,
since the source file is an assembly program. To turn on debug
information for an assembly program with a
.S
extension, you can use
sdcc
with the
-Wa
and
-dbg
options (the
-dbg
option is described in
Section 4.1.1.4, “Debugging Option (-dbg),” page 4-3
).
All assembly programs must be contained within a section.
Putting
.section “.text”, “ax”
before any assembly code ensures
that the code gets assembled into the .text section. Please refer to the
GNU assembler manual for more information on the section syntax and
flag definitions.
4.1.1 Assembler Options
Please refer to the GNU assembler manual for a full description of all
options available to the assembler. A few of the more frequently-used
options as well as the options specific for the SDK are described below.
4.1.1.1 Suppress warnings (-W)
This options prevents warnings from the assembler from being displayed
on the screen.