gpt4 book ai didi

assembly - Cortex M3 上的非 Thumb ARM 代码

转载 作者:行者123 更新时间:2023-12-02 21:28:12 27 4
gpt4 key购买 nike

我有一些 ARM 代码,正在尝试在 Cortex M3 上运行。我的大部分代码都是用 Thumb 编写的,从 C 编译 - 但对于某些功能,我希望能够运行普通的 ARM 代码(据我所知,这在 M3 上是可能的吗?)。

所以...

原始C代码和汇编:

int donothing(int a) {
return a;
}


00000068 <donothing>:
68: e52db004 push {fp} ; (str fp, [sp, #-4]!)
6c: e28db000 add fp, sp, #0
70: e24dd00c sub sp, sp, #12
74: e50b0008 str r0, [fp, #-8]
78: e51b3008 ldr r3, [fp, #-8]
7c: e1a00003 mov r0, r3
80: e28bd000 add sp, fp, #0
84: e8bd0800 ldmfd sp!, {fp}
88: e12fff1e bx lr

使用arm-none-eabi-gcc -mfloat-abi=soft -nostdinc -nostdlib编译

我使用 blx r4 分支到此 - 如果基地址&3 为 0(事实确实如此),则应该进行交换。

在 GDB 中单步执行此操作,一旦到达显示的行,即使地址包含正确的数据,它也会出现硬故障。

(gdb) p/x *0x2000934c 
$2 = 0xe52db004

代码(使用 BLX)非常适合 Thumb 代码...

知道发生了什么吗?谢谢!

最佳答案

Cortex-M 处理器不支持 ARM 模式指令。它们仅支持 Thumb-2,其中包括 16 位和 32 位指令的混合。无法在 Cortex-M 上运行 ARM 指令。

关于assembly - Cortex M3 上的非 Thumb ARM 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22996130/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com