Skip to content

Commit 0adc7dc

Browse files
kjbraceySenRamakri
authored andcommitted
RTX5: Make rtx_core_ca.h cope with compiler in Thumb mode
Assembler in rtx_core_ca.h is on the whole unified syntax such that it should work fine if assembled as either ARM or Thumb-2. The exception was __get_PSP, which uses STM^, which is only available in ARM state. Flagging for this function was incorrect, except for IAR - it switched assembler state without telling the compiler, meaning that the resulting assembler output could be incorrect, and that the function itself would not be correctly marked as an ARM function - the CPU would enter in Thumb state. Alternative fix would be to switch to System mode, which would work as either ARM or Thumb-2 assembler, like the rest of the file, but this is the minimal change. Fixes #526.
1 parent 0ef1620 commit 0adc7dc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

rtos/TARGET_CORTEX/rtx5/RTX/Source/rtx_core_ca.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,26 +104,26 @@ __STATIC_INLINE uint32_t StackOffsetR0 (uint8_t stack_frame) {
104104
/// Get xPSR Register - emulate M profile: SP_usr - (8*4)
105105
/// \return xPSR Register value
106106
#if defined(__CC_ARM)
107+
#pragma push
108+
#pragma arm
107109
static __asm uint32_t __get_PSP (void) {
108-
arm
109110
sub sp, sp, #4
110111
stm sp, {sp}^
111112
pop {r0}
112113
sub r0, r0, #32
113114
bx lr
114115
}
116+
#pragma pop
115117
#else
116118
#ifdef __ICCARM__
117119
__arm
120+
#else
121+
__attribute__((target("arm")))
118122
#endif
119123
__STATIC_INLINE uint32_t __get_PSP (void) {
120124
register uint32_t ret;
121125

122126
__ASM volatile (
123-
#ifndef __ICCARM__
124-
".syntax unified\n\t"
125-
".arm\n\t"
126-
#endif
127127
"sub sp,sp,#4\n\t"
128128
"stm sp,{sp}^\n\t"
129129
"pop {%[ret]}\n\t"

0 commit comments

Comments
 (0)