.equ STACK_BASE, 0x0c002000
.equ STACK_SIZE, 0x00001000
.text
ldr sp, = STACK_BASE
ldr sl, = STACK_BASE - STACK_SIZE
ldr pc, = entry
汇编结果为:
demo.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <.text>:
0: e59fd004 ldr sp, [pc, #4] ; c <.text+0xc>
4: e59fa004 ldr sl, [pc, #4] ; 10 <.text+0x10>
8: e59ff004 ldr pc, [pc, #4] ; 14 <.text+0x14>
c: 0c002000 stceq 0, cr2, [r0]
10: 0c001000 stceq 0, cr1, [r0]
14: 00000000 andeq r0, r0, r0
Disassembly of section .data:
其中第二列对应的就是arm指令的二进制代码
ldr指令所对应的32位二进制代码如下:
rel="File-List" href="file:///C:%5CDOCUME%7E1%5Czhw%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml">
.equ STACK_SIZE, 0x00001000
.text
ldr sp, = STACK_BASE
ldr sl, = STACK_BASE - STACK_SIZE
ldr pc, = entry
汇编结果为:
demo.o: file format elf32-littlearm
Disassembly of section .text:
00000000 <.text>:
0: e59fd004 ldr sp, [pc, #4] ; c <.text+0xc>
4: e59fa004 ldr sl, [pc, #4] ; 10 <.text+0x10>
8: e59ff004 ldr pc, [pc, #4] ; 14 <.text+0x14>
c: 0c002000 stceq 0, cr2, [r0]
10: 0c001000 stceq 0, cr1, [r0]
14: 00000000 andeq r0, r0, r0
Disassembly of section .data:
其中第二列对应的就是arm指令的二进制代码
ldr指令所对应的32位二进制代码如下:
rel="File-List" href="file:///C:%5CDOCUME%7E1%5Czhw%5CLOCALS%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml">
cond |
0 1 | I | P | U | 0 | W | 1 | Rn | Rd | addr_mode |
31 28 27 26 25 24 23 22 21 20 19 16 15 12 0
[31:28]:为条件码,默认情况下使用的条件码是AL,对应的二进制是1110
I P U W 以及addr_mode决定了地址模式
如例中,从反汇编中可以看出该地址模式为<Rn,+/-offset12>,因此对应的[I:P]为[0:1]
[27:24]:0101
U:如果U=1,表示是正偏移,即Rn+offset12,否则为负偏移
W:如果W=1,表示是字节传递,仅传送该地址的低8位,否则是字传递
[23:20]:[1001]
Rn:源寄存器 1111:15号寄存器 即PC
Rd:目的寄存器 1101:13号寄存器 即SP
所以e59ff004的含义就明确了