优龙Bootloader ARM汇编代码笔记
使用颜色编码整理笔记,提升记忆 #生活技巧# #学习技巧# #考试复习技巧#
GBLL THUMBCODE;全局的BOOL变量
[ {CONFIG} = 16
THUMBCODE SETL {TRUE}
CODE32
|
THUMBCODE SETL {FALSE}
]
$HandlerLabel
sub sp,sp,#4 ;decrement sp(to store jump address)
stmfd sp!,{r0} ;PUSH the work register to stack(lr does't push because it return to original address)
ldr r0,=$HandleLabel;load the address of HandleXXX to r0
ldr r0,[r0] ;load the contents(service routine start address) of HandleXXX
str r0,[sp,#4] ;store the contents(ISR) of HandleXXX to stack
ldmfd sp!,{r0,pc} ;POP the work register and pc(jump to ISR)
MEND
ARM IMPORT |Image
RO" role="presentation">RO
Limit| 的含义IMPORT |Image
RO" role="presentation">RO
Base| ; Base of ROM codeIMPORT |Image
RO" role="presentation">RO
Limit| ; End of ROM code (=start of ROM data)IMPORT |Image
RW" role="presentation">RW
Base| ; Base of RAM to initialiseIMPORT |Image
ZI" role="presentation">ZI
Base| ; Base and limit of areaIMPORT |Image
ZI" role="presentation">ZI
Limit| ; to zero initialiseIMPORT MMU_SetAsyncBusMode
IMPORT MMU_SetFastBusMode ;
IMPORT Main ; The main entry of mon program
............
对于刚学习ARM的人来说,如果分析它的启动代码,往往不明白下面几个变量的含义:|ImageROLimit|、|ImageRWBase|、|ImageZIBase|。
首先申明我使用的调试软件为ADS1.2,当我们把程序编写好以后,就要进行编译和链接了,在ADS1.2中选择MAKE按钮,会出现一个Errors and Warnings 的对话框,在该栏中显示编译和链接的结果,如果没有错误,在文件的最后应该能看到Image component sizes,后面紧跟的依次是Code,RO Data ,RW Data ,ZI Data ,Debug 各个项目的字节数,最后会有他们的一个统计数据:
Code 163632 ,RO Data 20939 ,RW Data 53 ,ZI Data 17028
Tatal RO size (Code+ RO Data) 184571 (180.25kB)
Tatal RW size(RW Data+ ZI Data) 17081(16.68 kB)
Tatal ROM size(Code+ RO Data+ RW Data) 184624(180.30 kB)
后面的字节数是根据用户不同的程序而来的,下面就以上面的数据为例来介绍那几个变量的计算。
在ADS的Debug Settings中有一栏是Linker/ARM Linker,在output选项中有一个RO base选项,下面应该有一个地址,我这里是0x0c100000(不是每个都一样的),后面的RW base 地址是0x0c200000,然后在Options选项中有Image entry point ,是一个初始程序的入口地址,我这里是0x0c100000 。
有了上面这些信息我们就可以完全知道这几个变量是怎么来的了:
|ImageROBase| = Image entry point = 0x0c100000 ;表示程序代码存放的起始地址
|ImageROLimit|=程序代码起始地址+代码长度+1=0x0c100000+Tatal RO size+1
= 0x0c100000 + 184571 + 1 = 0x0c100000 +0x2D0FB + 1
= 0x0c12d0fc
|ImageRWBase| = 0x0c200000 ;由RW base 地址指定
|ImageRWLimit| =|ImageRWBase|+ RW Data 53 = 0x0c200000+0x37(4的倍数,0到55,共56个单元)
=0x0c200037
|ImageZIBase| = |ImageRWLimit| + 1 =0x0c200038
|ImageZILimit| = |ImageZIBase| + ZI Data 17028
=0x0c200038 + 0x4284
=0x0c2042bc
也可以由此计算:
|ImageZILimit| = |ImageRWBase| +TatalRWsize(RWData+ZIData) 17081
=0x0c200000+0x42b9+3(要满足4的倍数)
=0x0c2042bc
网址:优龙Bootloader ARM汇编代码笔记 https://www.yuejiaxmz.com/news/view/134978
相关内容
【读书笔记】代码大全26章:代码优化技术【TINY4412】LINUX移植笔记:(23)设备树LCD触摸屏驱动
笔记
C++笔记
【惠普战66 七代 锐龙版 16英寸 R5 7535U/16GB/512GB/120Hz评测】HP 战66 七代 锐龙版 16英寸 R5 7535U/16GB/512GB/120Hz笔记本电脑评测
【必备】生活日记汇编8篇
[C2000]代码中提示 fp
感受生活随笔(汇编15篇)
基于ARM的室内空气质量检测系统研究.pdf
碎片时代生存法 “印象笔记”整理精致生活