[英]arm32 cross compiling giving compiling error in right assembly code
所以,我需要運行我已經完成的某個 arm32 代碼。 代碼沒問題並且使用 Keil 在我的 Windows 機器上運行,但是當我嘗試在 Ubuntu 交叉編譯器上運行時(使用arm-linux-gnueabihf-as prgm1.s -o asm32.o && arm-linux-gnueabihf-ld -static asm32.o -o asm32
) 對於 arm32 它給出了很多語法錯誤。 我想也許我在錯誤的架構上運行,但我根本找不到合適的架構。 在 Keil 上,我選擇運行的設備是 LPC2104。 Ubuntu 交叉編譯器中是否有任何設備規范? 或者我可以用來運行它的另一個程序? 代碼和錯誤如下:
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
和錯誤(對不起,我不知道如何將其更改為英文):
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'
匯編語言特定於工具(gas、armasm 等)而不是目標 (ARM)。 這些是不同且不兼容的編程語言。
可能只是擺脫這個或尋找替代品。
AREA prgm1, CODE, READONLY
ENTRY
main MOV R1, #2
BL func1
MOV R9, R8 ;MOV F(2) into R9
MOV R1, #5
BL func1
標簽必須有一個冒號。 Gas,使用@ 作為注釋而不是大多數匯編語言使用的注釋;
main: MOV R1, #2
BL func1
MOV R9, R8 ;@MOV F(2) into R9
MOV R1, #5
BL func1
我喜歡放 ;@ 並且它對兩者都有效,或者至少你的文本編輯器可能會更快樂。
這可能會涵蓋這里的所有問題。 也許 .end 而不是 end 或者只是將其注釋掉。
除非您將它們聲明為全局標簽,否則假定標簽是本地的
.globl main
...
main:
同樣,您想將其聲明為函數。
.globl main
.type main, %function
...
main:
以便它鏈接正確。 與其他匯編器一樣,您需要指定目標架構(armv4t、armv6-m、armv7-a 等)。 如果您使用統一語法
.syntax unified
某處頂部(同樣根據需要使用 .thumb)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.