摘要: 本文主要對Arm Compiler 6編譯器的 GNU匯編和armasm 匯編進(jìn)行介紹。
關(guān)鍵字:Arm Compiler 6、編譯器、 GNU匯編、armasm 匯編。
Arm Compiler 6可以為GUN語法匯編和armasm匯編語法進(jìn)行編譯。GUN和armasm兩種匯編代碼有著不同的語法。它們有很多相似之處,也有不同之處。
1. GNU匯編
通過.section偽操作來自定義一個段;匯編行都是如下結(jié)構(gòu)
[<label>:][<instruction or directive or pseudo-instruction>} //comment
??????????<label>: 為標(biāo)號, GNU匯編中,任何以冒號結(jié)尾的標(biāo)識符都被認(rèn)為是一個標(biāo)
instruction為指令
directive為偽操作
pseudo-instruction為偽指令
??????????comment為語句的注釋
// Simple GNU syntax example
// Iterate round a loop 10 times, adding 1 to a register each time.
.section .text,"ax"
.balign 4
main:
MOV ?????w5,#0x64 ?????// W5 = 100
MOV ?????w4,#0 ????????// W4 = 0
B ???????test_loop ????// branch to test_loop
loop:
ADD ?????w5,w5,#1 ?????// Add 1 to W5
ADD ?????w4,w4,#1 ?????// Add 1 to W4
test_loop:
CMP ?????w4,#0xa ??????// if W4 < 10, branch back to loop
BLT ?????loop
.end
對于GNU語法需要使用armclang集成匯編器來匯編 GNU 匯編代碼。如下示例:
armclang --target=aarch64-arm-none-eabi -c -o file.o file.S
2. armasm 匯編
armasm匯編格式:MNEMONIC{S}{condition} {Rd}, Operand1, Operand2
MNEMONIC ????- 指令簡稱(助記符)
{S} ?????????- 可選后綴
{condition} ?- 執(zhí)行指令條件
{Rd} ????????- 用于存儲結(jié)果的寄存器(目的寄存器)
Operand1 ????- 操作數(shù)1
Operand2 ????- 操作數(shù)2
; Simple armasm syntax example
; Iterate round a loop 10 times, adding 1 to a register each time.
AREA ||.text||, CODE, READONLY, ALIGN=2
main PROC
MOV ?????w5,#0x64 ?????; W5 = 100
MOV ?????w4,#0 ????????; W4 = 0
B ???????test_loop ????; branch to test_loop
loop
ADD ?????w5,w5,#1 ?????; Add 1 to W5
ADD ?????w4,w4,#1 ?????; Add 1 to W4
test_loop
CMP ?????w4,#0xa ??????; if W4 < 10, branch back to loop
BLT ?????loop
ENDP
END
對于armasm匯編需要使用armasm匯編器來匯編代碼。如下示例:
armasm --cpu=8-A.64 -o file.o file.s
來源:《Arm? Compiler for Embedded User Guide Version 6.18》
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
關(guān)于億道電子
億道電子技術(shù)有限公司(英文名稱:Emdoor Electronics Technology Co.,Ltd)是國內(nèi)資深的研發(fā)工具軟件提供商,公司成立于 2002 年,面向中國廣大的制造業(yè)客戶提供研發(fā)、設(shè)計、管理過程中使用的各種軟件開發(fā)工具,致力于幫助客戶提高研發(fā)管理效率、縮短產(chǎn)品設(shè)計周期,提升產(chǎn)品可靠性。
20 年來,先后與 Altium、ARM、Ansys、QT、Adobe、Visu-IT、Minitab、Testplant、EPLAN、HighTec、GreenHills、PLS、Ashling、MSC Software 、Autodesk、Source Insight、TeamEDA、MicroFocus等多家全球知名公司建立戰(zhàn)略合作伙伴關(guān)系,并作為他們在中國區(qū)的主要分銷合作伙伴服務(wù)了數(shù)千家中國本土客戶,為客戶提供從芯片級開發(fā)工具、EDA 設(shè)計工具、軟件編譯以及測試工具、結(jié)構(gòu)設(shè)計工具、仿真工具、電氣設(shè)計工具、以及嵌入式 GUI 工具等等。億道電子憑借多年的經(jīng)驗積累,真正的幫助客戶實現(xiàn)了讓研發(fā)更簡單、更可靠、更高效的目標(biāo)。

歡迎關(guān)注“億道電子”公眾號
了解更多研發(fā)工具軟件知識

首頁 > 新聞資訊
