Datasheet
Creating an Application
3-16 Copyright © 1999-2001 ARM Limited. All rights reserved. ARM DUI 0064D
3.3.2 Using the assembler from the command line
The basic syntax to use the ARM assembler (armasm) from the command-line is:
armasm {inputfile}
For example, to assemble the code in a file called
myfile.s
, type:
armasm -list myfile.lst myfile.s
This produces an object file called
myfile.o
, and a listing file called
myfile.lst
.
For full details of the command-line options and syntax, refer to the ADS Assembler
Guide.
Example 3-1 shows a small interworking ARM/Thumb assembly language program.
You can use it to explore the use of the assembler, linker, and the ARM symbolic
debugger.
Example 3-1
AREA AddReg,CODE,READONLY ; Name this block of code.
ENTRY ; Mark first instruction to call.
main
ADR r0, ThumbProg + 1 ; Generate branch target address and set bit 0
; hence arrive at target in Thumb state.
BX r0 ; Branch and exchange to ThumbProg.
CODE16 ; Subsequent instructions are Thumb code.
ThumbProg
MOV r2, #2 ; Load r2 with value 2.
MOV r3, #3 ; Load r3 with value 3.
ADD r2, r2, r3 ; r2 = r2 + r3
ADR r0, ARMProg ; Generate branch target address with bit 0 zero.
BX r0 ; Branch and exchange to ARMProg.
CODE32 ; Subsequent instructions are ARM code.
ARMProg
MOV r4, #4
MOV r5, #5
ADD r4, r4, r5
stop MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SWI 0x0123456 ; ARM semihosting SWI
END ; Mark end of this file.