Unformatted text preview: e into multiple source files. Each
source file (which has the extension .s) is then assembled using a command line
similar to the one shown.
Once you have assembled all of your source files into binary object files (with the
extension .o), you use the GNU Linker to create the final executable (extension .elf).
This is done by executing:
arm-elf-ld -o filename.elf filename.o
Once again, replace filename with whatever is appropriate for your project. If you
are using multiple source files (and hence multiple object files), replace filename.o
with a list of all object files in your project. Typing these commands again and again becomes rather tedious (even though the
Unix shell allows you to use the Up Arrow key to retrieve previous command lines).
For this reason, a template Makefile has been supplied that you can modify to suit
your own purposes (it can be found as examples/templates/Makefile.template-asm on
the CD-ROM). Once you have modified this file (and renamed it to Makefile), all you
need to do to recreate the executable is type:
make Assembly Language Syntax
The GNU Assembler is actually an assembler that can target many different CPU
architectures, not just the ARM. For this reason, its syntax is slightly different from
other ARM assemblers; the GNU Assembler uses the same syntax for all of the 45odd CPU architectures that it supports.
Assembly language source files consist of a sequence of statements, one per line.
Each statement has the following format, each part of which is optional:
label: instruction ; comment A label allows you to identify the location of the program counter (ie, its address) at
that point in the program. This label can then be used, for example, as a target for
branch instructions or for load and store instructions. A label can be any valid symbol, followed by a colon “:”. A valid symbol, in turn, is one that only uses the alphabetic characters A to Z and a to z (case does matter, ie, is significant), the digits 0 to
9, as well as “_”, “.” and “$”. Note, however, t...
View Full Document
- Assembly Language, GNU Assembler, GNU Assembler Reference