简体   繁体   中英

Non-Thumb ARM code on Cortex M3

I've got some ARM code that I'm trying to run on the Cortex M3. 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?).

So...

Original C code and assembly:

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

I branch to this with blx r4 - which should exchange if the base address&3 is 0, which it is.

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) p/x *0x2000934c 
$2 = 0xe52db004

The code (with BLX) works perfectly for Thumb code though...

Any idea what's going on? Thanks!

Cortex-M processors do not support ARM mode instructions. They only support Thumb-2, which includes a mixture of 16 and 32-bit instructions. There is no way to run ARM instructions on a Cortex-M.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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