This preview shows page 1. Sign up to view the full content.
Unformatted text preview: olute number of bytes (the difference
between code_end and code_start).
The other symbols, first_instr,
instr_11th and instr_10th, are all relative to the start of the .text section: their
exact value is only set when the final executable is created.
In general, the following rules apply to relative expressions:
absolute All other expressions involving relative values are not allowed (except, of course, for
the simple case of a symbol by itself). Note also that relative symbols must be in the
same section: you cannot find the difference between a label in the .text section and
one in the .data section, for example.
You may find more information about relative expressions, if you need it, in section 4.1 of the GNU Assembler Reference. –6– Example Files
As already mentioned, the examples directory and its subdirectories on your CDROM contain many examples of assembly language programs. These example files
illustrate various aspects of the GNU Assembler for the ARM microcontroller. You
are encouraged to study these examples—at the very least, you should quickly look
In particular, the examples/intro directory contains the following example files; these
files should be studied in the order presented:
strcopy-c.c A simple ARM assembly language program, with which to start
Simple subroutines (function calls)
Load constant values into registers, with ldr =
More information about pseudo-instructions for the ARM
Multi-way branches and pointers to functions
Copy an array of words, stored in the .data section
Copy an array en-masse, with stack pointer initialisation
Copy a NUL-terminated string to a buffer (assembler module)
String copy using multiple source files, using copy.s
Mixing C and assembler for string copy, using copy.s You can create the associated executable files by copying all files in that directory to
a temporary one, then use make:
mkdir –p ~/intro
cp * ~/intro
chmod 644 *
make all #
# Create a directory to hold the files
Assumes CD-ROM is mounted on /mnt/cdrom
Copy the files
Change to that directory
Make the files read/writable
Create the executables You can use the simulator provided by either arm-elf-gdb or arm-elf-insight to
actually run the executable files; see An Introduction to the GNU Debugger for more
details. More Information
You can find more information about the GNU Assembler in the GNU Assembler Reference, also called Using AS. This 200-odd-page document is fairly comprehensive,
although not particularly user-friendly.3 It can be found in the gnutools/doc directory on your CD-ROM.
The definitive reference is the actual source code to the GNU Assembler. You can
find this on the CD-ROM in the file gnutools/src/binutils-version.tar.gz for some version number. After unpacking this archive (and applying the appropriate patch file),
try browsing the source code files in the gas subdirectory. If you think you can do better, you can always try! That is one of the advantages of having a
program with free access to the source code… 3 –7–...
View Full Document
- Assembly Language