【发布时间】:2020-07-30 14:46:33
【问题描述】:
我正在练习汇编编程,我的疑问是 arm-none-eabi-ld -Ttext=0x20 -o add.elf。标签从 0x20 到 0x2C 获取地址,因为有 4 条指令,每条指令是 4 个字节。程序计数器包含要获取的指令的地址,这里 R15 是 PC,它包含值 0x0C。它如何保存 0x0C,它应该有地址 0x2C。那么arm-none-eabi-ld -Ttext=0x20 -o add.elf有什么用,将文本部分放在0x20。我是菜鸟,所以如果用简单的术语和逐步的解释会很有帮助。
- arm-none-eabi-as add.s -o add.o
start:
mov r0, #5
mov r1, #2
add r2, r1, r0
stop:
b stop
arm-none-eabi-ld -Ttext=0x20 -o add.elf.
user@stretch:~/Desktop/Gnu_Toolchain/Adding_Two_Numbers$ arm-none-eabi-nm -n add.elf
U _start
**00000020** t start
0000002c t stop
qemu-system-arm -M connex -pflash flash.bin -nographic -serial /dev/null
info registers
R00=00000005 R01=0000000c R02=00000011 R03=00000000
R04=00000000 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00000000 R14=00000000 **R15=0000000c**
【问题讨论】:
-
不清楚你是如何运行代码的。也许您将它加载到地址为零,即使它链接到
0x20。
标签: assembly arm microcontroller microprocessors