Reputation: 266
I have to ask it... It literally has driven me crazy for days already. After the choosing as toolchain an arm-none-eabi my life became a kind of nightmare and the reason is a very simple - arm-none-eabi-as treats every comment as an instruction and moreover sometimes it just doesn't understand an ARM assembler throwing fancy errors like "AREA is a bad instruction"...
Here is the code I copied and paste from the keil's docs:
AREA Loadcon, CODE, READONLY
ENTRY ; Mark first instruction to execute
start
BL func1 ; Branch to first subroutine
BL func2 ; Branch to second subroutine
stop
MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SVC #0x123456 ; ARM semihosting (formerly SWI)
func1
LDR r0, =42 ; => MOV R0, #42
LDR r1, =0x55555555 ; => LDR R1, [PC, #offset to
; Literal Pool 1]
LDR r2, =0xFFFFFFFF ; => MVN R2, #0
BX lr
LTORG ; Literal Pool 1 contains
; literal Ox55555555
func2
LDR r3, =0x55555555 ; => LDR R3, [PC, #offset to
; Literal Pool 1]
; LDR r4, =0x66666666 ; If this is uncommented it
; fails, because Literal Pool 2
; is out of reach
BX lr
LargeTable
SPACE 4200 ; Starting at the current location,
; clears a 4200 byte area of memory
; to zero
END ; Literal Pool 2 is empty
My question is: What flags should I use to make arm-none-eabi-as to understand its very own assembler instructions and treat comments as comments?
*ADDED: * Here is the command I'm using to compile this code:
arm-none-eabi-gcc hello.S -Os -g -mthumb -mcpu=cortex-m3 -msoft-float -o hello.elf
Upvotes: 1
Views: 4519
Reputation: 28087
One should check gnu as
's documentation. Generally every architecture has its own differences about syntax. ARM is no different.
Upvotes: 1
Reputation: 58427
The default character for starting a single-line comment in GNU's ARM assembly syntax is @
IIRC. As in:
BL func1 @ Branch to first subroutine
As for the assembler directives; they are assembler-specific, so you can't just take armasm code and assemble it with GNU's assembler, or vice versa. You'll have to look up what each directive means and try to find a corresponding one for the assembler you're going to use.
For example, to replace AREA Loadcon, CODE, READONLY
you could probably use .text
(unless you need to be able to refer to the section by its name).
Upvotes: 5
Reputation: 71506
The gnu assembler is well known for making up its own assembly language to replace well established syntaxes. Basically your arm assembler syntax as written wont work with gnu. As far as comments go I prefer to use a combination of both ;@ for my comments, beyond that you will need to figure out syntax that is common between both, at one point when I was developing for both I would/could write code that assembled on both, but I dont have access any more.
yes this is very frustrating...
Upvotes: 1