简体   繁体   English

Cortex M3上的非拇指ARM代码

[英]Non-Thumb ARM code on Cortex M3

I've got some ARM code that I'm trying to run on the Cortex M3. 我有一些要在Cortex M3上运行的ARM代码。 The majority of my code in written in Thumb, compiled from C - but for some functions I'd like to be able to run normal ARM code (as I understand it, this is possible on the M3?). 我的大部分代码都是用Thumb编写的,是从C编译的-但是对于某些功能,我希望能够运行普通的ARM代码(据我了解,这在M3上可能吗?)。

So... 所以...

Original C code and assembly: 原始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

Compiled using arm-none-eabi-gcc -mfloat-abi=soft -nostdinc -nostdlib 使用arm-none-eabi-gcc -mfloat-abi=soft -nostdinc -nostdlib

I branch to this with blx r4 - which should exchange if the base address&3 is 0, which it is. 我用blx r4分支到它-如果基地址&3是0,它应该交换。

Stepping through this in GDB, it HardFaults as soon as it gets to the line shown, even though the address contains the right data. 在GDB中逐步执行此操作,即使地址包含正确的数据,它也会在到达显示的行时立即进行HardFaults处理。

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

The code (with BLX) works perfectly for Thumb code though... 该代码(带有BLX)可完美地用于Thumb代码...

Any idea what's going on? 知道发生了什么吗? Thanks! 谢谢!

Cortex-M processors do not support ARM mode instructions. Cortex-M处理器不支持ARM模式指令。 They only support Thumb-2, which includes a mixture of 16 and 32-bit instructions. 它们仅支持Thumb-2,其中包含16位和32位指令的混合。 There is no way to run ARM instructions on a Cortex-M. 无法在Cortex-M上运行ARM指令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM