一個簡單的 as file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.syntax unified | |
.text | |
.thumb | |
.global func1 | |
.type func1, %function | |
func1: | |
mov r1, #1 | |
tst r1, #0x1 | |
ite eq | |
moveq r2, #0x90000000 | |
movne r2, #0x30000000 | |
orr.w r2, #0x1 | |
bx r2 |
line 1: 必須要有這行。沒有的話 compiler 會跳出奇怪的訊息,而且看不出來要加這一行。 像我碰到的就是下面這些 ,
Error: unshifted register requiredline 3: Must. 告訴 assembler 要用 Thumb ISA
Error: Thumb does not support conditional execution
Error: instruction not allowed in IT block
line 6: Must. 告訴 linker 這個 label 是個 funciton,用到這個symbol 的地方都要自動使用 thumb mode,也就是要把 bit 0 設定成 1。不然就會碰到當呼叫這個 function 時就產生 Usage fault。當然,如果這不是個 function ,只是一個變數的 lable,就不用加這個了。
https://e2e.ti.com/support/microcontrollers/stellaris_arm/f/471/t/44006?Q-bit-0-of-reset-vector-must-be-1-
line 11~14: 假設想跳到某個指定的位址時,若是使用 register 來存目標位址,就必須自己assert bit 0。原因跟上一個一樣,也是很常碰到的問題。
ARM directives list
https://sourceware.org/binutils/docs/as/ARM-Directives.html