Writing ARM and Thumb Assembly Language
ARM DUI 0068B
Copyright © 2000, 2001 ARM Limited. All rights reserved.
2-15
2.3.2
An example ARM assembly language module
Example 2-1 illustrates some of the core constituents of an assembly language module.
The example is written in ARM assembly language. It is supplied as
armex.s
in the
examples\asm
subdirectory of ADS. Refer to
Code examples
on page 2-2 for instructions
on how to assemble, link, and execute the example.
The constituent parts of this example are described in more detail in the following
sections.
Example 2-1
AREA ARMex, CODE, READONLY
; Name this block of code ARMex
ENTRY ; Mark first instruction to execute
start
MOV r0, #10 ; Set up parameters
MOV r1, #3
ADD r0, r0, r1 ; r0 = r0 + r1
stop
MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SWI 0x123456 ; ARM semihosting SWI
END ; Mark end of file
ELF sections and the AREA directive
ELF
sections
are independent, named, indivisible sequences of code or data. A single
code section is the minimum required to produce an application.
The output of an assembly or compilation can include:
•
One or more code sections. These are usually read-only sections.
•
One or more data sections. These are usually read-write sections. They may be
zero initialized
(ZI).
The linker places each section in a program image according to section placement rules.
Sections that are adjacent in source files are not necessarily adjacent in the application
image. Refer to the
Linker
chapter in
ADS Linker and Utilities Guide
for more
information on how the linker places sections.