之前斷斷續續看arm,啥也沒學到的感覺。開始系統學習arm,堅持下來,從arm開發環境,到arm模擬器實際執行。gnu as彙編編譯語法
摘自skyeye arm_hello的**
start.s:
#define mode_svc 0x13#define i_bit 0x80.text
.align 4.
global
begin
.type begin, function
begin:
/*disable i-bit
*/mov r0, #i_bit|mode_svc
msr cpsr_c, r0
//設定狀態暫存器,i位為1,禁止irq中斷
ldr sp, =irq_stack @ set sp_irq =irq_stack
bl hello
//跳轉到hello,子程式呼叫
b begin //
又跳轉到begin
.data
.align
4irq_stack:
.space
4096
hello.c:
#define bogo_mips 1000000void hello(void
) }
return
;
}
hello.lds:
output_arch(arm)entry(begin)
//符號begin設定為入口位址
sections
. = align(8192
); .data :
.bss :
/*stabs debugging sections.
*/.stab
0 :
.stabstr
0 :
.stab.excl
0 :
.stab.exclstr
0 :
.stab.index
0 :
.stab.indexstr
0 :
.comment
0 :
.debug_abbrev
0 :
.debug_info
0 :
.debug_line
0 :
.debug_pubnames
0 :
.debug_aranges
0 :
}
makefile:
cc=arm-elf-gccld=arm-elf-ld
cflags= -c -wall -wstrict-prototypes -wno-trigraphs -o2 -pipe -g -mapcs-32 -march=armv4 -mtune=arm7tdmi
ldflags= -n -p -x -thello.lds
lib=all: hello
hello: start.o hello.o
$(ld) $(ldflags) start.o hello.o -o hello
arm-elf-objdump -xs hello >hello.s
arm-elf-readelf -a hello >hello.r
arm-elf-nm hello >hello.n
start.o:start.s
$(cc) $(cflags) start.s
hello.o:hello.c
$(cc) $(cflags) hello.c
clean:
rm -rf *.o *.elf *.gdb hello *.r *.n *.s
refer link:
skyeye安裝文章
arm彙編開發環境,不用ide環境,使用arm-elf-tools交叉編譯環境
arm彙編編寫
ldr mov區別
skyeye例項解析
arm 彙編學習
一 暫存器和定址 arm有16個暫存器,r0 r15 pc r15 lr r14 sp r13 ip r12 push sp減少,pop sp增加 1.定址方式 從操作位址尋找運算元的方式 2.arm的定址方式 a 暫存器定址,運算元在暫存器中 b 立即定址,運算元就在指令中 subs r0,r0,...
ARM彙編學習
前言 任何彙編行都是如下結構 comment 注釋 gnu arm 彙編中,任何以冒號結尾的都被認為是乙個標籤,而不一定非要在一行的開始。下面是乙個簡單的例子,這段匯程式設計序定義了乙個 add 的函式,該函式返回兩個引數的和 section text,x global add give the s...
ARM彙編學習
前言 任何彙編行都是如下結構 comment 注釋 gnu arm 彙編中,任何以冒號結尾的都被認為是乙個標籤,而不一定非要在一行的開始。下面是乙個簡單的例子,這段匯程式設計序定義了乙個 add 的函式,該函式返回兩個引數的和 section text,x global add give the s...