我使用 Gem5 来获取 ARM 处理器的指令访问。我使用 -marm 选项生成代码。
arm-linux-gnueabihf-gcc -static -marm fibcall.c
我相信使用此选项只会生成 32 位 ARM 指令。但结果如下所示:
command line: ./build/ARM/gem5.opt --debug-flags=Exec configs/example/se.py -c tests/test-progs/malardalen/a.out
Global frequency set at 1000000000000 ticks per second
**** REAL SIMULATION ****
info: Entering event queue @ 0. Starting simulation...
0: system.cpu T0 : @fini+15 : mov.w fp, #0 : IntAlu : D=0x0000000000000000
500: system.cpu T0 : @_start+3 : mov.w lr, #0 : IntAlu : D=0x0000000000000000
1000: system.cpu T0 : @_start+7 : ldmstm
1000: system.cpu T0 : @_start+7.0 : ldr_uop r1, [sp, #0] : MemRead : D=0x0000000000000001 A=0xbeffff00
1500: system.cpu T0 : @_start+7.1 : addi_uop sp, sp, #4 : IntAlu : D=0x00000000beffff04
2000: system.cpu T0 : @_start+9 : mov r2, sp : IntAlu : D=0x00000000beffff04
2500: system.cpu T0 : @_start+11 : ldmstm
2500: system.cpu T0 : @_start+11.0 : str_uop r2, [sp, #4] : MemWrite : D=0x00000000beffff04 A=0xbeffff00
3000: system.cpu T0 : @_start+11.1 : subi_uop sp, sp, #4 : IntAlu : D=0x00000000beffff00
3500: system.cpu T0 : @_start+13 : ldmstm
3500: system.cpu T0 : @_start+13.0 : str_uop r0, [sp, #4] : MemWrite : D=0x0000000000000000 A=0xbefffefc
4000: system.cpu T0 : @_start+13.1 : subi_uop sp, sp, #4 : IntAlu : D=0x00000000befffefc
4500: system.cpu T0 : @_start+15 : ldr.w r12, [pc, #16] : MemRead : D=0x0000000000009039 A=0x88d8
5000: system.cpu T0 : @_start+19 : str.w r12, [sp, #-4]!
5000: system.cpu T0 : @_start+19.0 : str.w r12, [sp, #-4]! : MemWrite : D=0x0000000000009039 A=0xbefffef8
5500: system.cpu T0 : @_start+19.1 : subi_uop.w sp, sp, #4 : IntAlu : D=0x00000000befffef8
6000: system.cpu T0 : @_start+23 : ldr r0, [pc, #12] : MemRead : D=0x0000000000008a4c A=0x88dc
...
我们可以看到,在 2000 年,使用了 _start+9,即 _start+7 的 2 个字节。所以我认为使用了 16 位指令。为什么会这样?为什么不是32位?
另外,有谁知道 _start+7.0 和 _start+7.1 是什么意思?为什么我有两条不同的指令具有相同的内存地址?
提前致谢。