历史上的今天
今天是:2025年04月15日(星期二)
2018年04月15日 | TQ2440之uboot---7.start.S中关于bl指令的理解
2018-04-15 来源:eefocus
编译u-boot时,在Makefile 的ALL变量最后加上$(obj)u-boot.dis,会编译出u-boot.dis,u-boot.dis是通过arm-linux-objdum –d 生成u-boot的每一条指令的反汇编。
33d80080: e59f13f4 ldr r1, [pc, #1012]
33d80084: e59f03f4 ldr r0, [pc, #1012]
33d80088: e5801000 str r1, [r0]
33d8008c: eb000015 bl 33d800e8
………
33d800e8 :
33d800e8: e3a00000 mov r0, #0 ; 0x0
上面的bl指令,从表面上看 bl 33d800e8,好像是跳到了绝对地址0x33d800e8处,此时是运行在绝对0x0地址处,然后用bl一下子跳到了内存地址0x33d800e8处,可是此时内存都还没有初始化就运行,这怎么可能?
这好像是很矛盾,但仔细分析一下,原来是这样的:
将 eb000015 转为二进制:
1110 1011 0000 0000 0000 0000 0001 0101

看一下它的具体含义,下面是b/bl 指令的格式-- 出自《ARM Instruction Set》
31-28 –> cond
27-25 –> 101
24 --> L
23-0 –> offset
"Branch instructions contain a signed 2's complement 24 bit offset. This is shifted left two bits, sign extended to 32 bits, and added to the PC. The instruction can therefore specify a branch of +/- 32Mbytes. The branch offset must take account of the prefetch operation, which causes the PC to be 2 words (8 bytes) ahead of the current instruction. Branches beyond +/- 32Mbytes must use an offset or absolute destination which has been previously loaded into a register. In this case the PC should be manually saved in R14 if a Branch with Link type operation is required.“ 出自《ARM Instruction Set》
1110 –> cond –> always 无条件跳转
27-25 –> 说明是B 跳转指令
24 –> L位 Branch with Link, 跳转时将下一条指令的地址拷贝到R14(lr)中
23-0 –> offset=0x15
执行bl后:pc = 当前pc + ( offset<<2 + 8 ) = 0x8c+(0x15<<2+8)= 0xE8
跳到偏移地址为0xE8的地方,也就是 cpu_init_crit函数中。
史海拾趣
|
求S3C2440的引导注释,或者求语言达人给出下面韩文的翻译。先谢谢了! 文章地址:http://hompy.nugu.com/board/board_template.aspx?idx=18810&folder=0&list=0&bt=read&word=&field=content&page=1&pagesize=10&hcid=kbuilder&cid=… 查看全部问答> |
|
Error 0x80000200/-1135 Fatal Error Error connecting to the target: Error 0x80000200/-1135 Fatal Error during: OCS, Unrecoverable emulation error 晶振应该是起振的,不知道还应该检查什么地方?… 查看全部问答> |
|
这几天也买了几片MMA7455片子,还没有开始玩;一直在找资料;突然看到这里有个专区讨论很是高兴;不过也可惜的就是问的多答得少。做出来的多;开源的少。 也可能是出来不懂,也后多学学了; 我从网 ...… 查看全部问答> |
|
电动汽车作为一种发展前景广阔的绿色交通工具,今后的普及速度会异常迅猛,未来的市场前景也是异常巨大的。在全球能源危机和环境危机严重的大背景下,我国政府积极推进新能源汽车的应用与发展,充/换电站作为发展电动汽车所必须的重要配套基 ...… 查看全部问答> |




