So, I need to run a certain arm32 code that I've done. The code is alright and running on my Windows machine using Keil, however when I try to run on the Ubuntu cross compiler (using arm-linux-gnueabihf-as prgm1.s -o asm32.o && arm-linux-gnueabihf-ld -static asm32.o -o asm32
) for arm32 it gives a lot of syntax errors. I think maybe I'm running on the wrong architecture, but I simply cannot find the right one. On Keil the device that I've chose to run was LPC2104. Is there any device specifications in the Ubuntu cross compiler? Or another program I can use to run it?
The code and errors goes as following:
AREA prgm1, CODE, READONLY
ENTRY
main MOV R1, #2
BL func1
MOV R9, R8 ;MOV F(2) into R9
MOV R1, #5
BL func1
stop B stop
func2 MUL R2, R6, R3 ;Multiplies bk with x0
ADD R0, R5, R2 ;Adds the results of the previous line with ak-1
BX LR ;Output Value
func1 MOV R6, #1 ;MOV the first coefficient into R6
MOV R5, #3 ;MOV the second coefficient into R5
MOV R3, R1 ;MOV the input to R3
PUSH{LR} ;Pushes back to the main
BL func2 ;Call function to output
MOV R6, R0 ;MOV the ouput value to R6
MOV R5, #5 ;Third Coefficient
BL func2
MOV R6, R0
MOV R5, #7
BL func2
MOV R6, R0
MOV R5, #9
BL func2
MOV R8, R0
POP{LR} ;POP LR from the stack
BX LR
END
And the error (sorry, I don't know how to change it to english):
prgm1.s:12: Erro: instrução inválida `area prgm1,CODE,READONLY'
prgm1.s:13: Erro: instrução inválida `entry '
prgm1.s:15: Erro: instrução inválida `main MOV R1,#2'
prgm1.s:17: Erro: registrador ARM esperado -- `mov F(2)into R9'
prgm1.s:22: Erro: instrução inválida `stop B stop'
prgm1.s:24: Erro: instrução inválida `func2 MUL R2,R6,R3'
prgm1.s:24: Erro: instrução inválida `multiplies bk with x0'
prgm1.s:25: Erro: registrador ARM esperado -- `adds the results of the previous line with ak-1'
prgm1.s:26: Erro: instrução inválida `output Value'
prgm1.s:29: Erro: instrução inválida `func1 MOV R6,#1'
prgm1.s:29: Erro: registrador ARM esperado -- `mov the first coefficient into R6'
prgm1.s:30: Erro: registrador ARM esperado -- `mov the second coefficient into R5'
prgm1.s:31: Erro: registrador ARM esperado -- `mov the input to R3'
prgm1.s:32: Erro: instrução inválida `push{LR}'
prgm1.s:32: Erro: instrução inválida `pushes back to the main'
prgm1.s:33: Erro: instrução inválida `call function to output'
prgm1.s:34: Erro: registrador ARM esperado -- `mov the ouput value to R6'
prgm1.s:35: Erro: instrução inválida `third Coefficient'
prgm1.s:44: Erro: instrução inválida `pop{LR}'
prgm1.s:44: Erro: expressão muito complexa -- `pop LR from the stack'
prgm1.s:46: Erro: instrução inválida `end'
Assembly language is specific to the tool (gas, armasm, etc) not the target (ARM). These are different and incompatible programming languages.
Probably just get rid of this or look for an alternative.
AREA prgm1, CODE, READONLY
ENTRY
main MOV R1, #2
BL func1
MOV R9, R8 ;MOV F(2) into R9
MOV R1, #5
BL func1
Labels must have a colon. Gas, uses @ for a comment rather than the one used by most assembly languages ;
main: MOV R1, #2
BL func1
MOV R9, R8 ;@MOV F(2) into R9
MOV R1, #5
BL func1
I like to put ;@ and it works for both or at least your text editor might be happier.
That will cover maybe all of the issues here. Maybe .end instead of end or just comment it out.
The labels are assumed local unless you declare them global
.globl main
...
main:
Likewise you want to declare it a function.
.globl main
.type main, %function
...
main:
So that it links right. And as with the other assemblers you need to specify the target architecture (armv4t, armv6-m, armv7-a, etc). And if you are using the unified syntax
.syntax unified
somewhere up top (likewise .thumb as needed)