Skip to content

Commit 734fa18

Browse files
stephanosiokartben
authored andcommitted
arch: arm: cortex_m: Use Thumb-1 compatible 'mov reg, imm' mnemonic
The ARM Thumb-1 instruction set, used by ARMv6-M and ARMv8-M Baseline cores, does not have a valid encoding for "immediate-to-register move without affecting flags" instruction (i.e. `mov reg, imm`), and the only valid variant of immediate-to-register move instruction for it is `movs`, which affects the flags. Since none of the register initialisation instructions used here are flag-sensitive in their context, this commit changes `mov` to `movs`. This fixes the compilation errors with Clang/LLVM, which is more picky about the `mov` mnemonic usage and prints out an "invalid instruction" error when `mov reg, imm` is specified in Thumb-1 mode. Note that GNU assembler implicitly converts `mov reg, imm` to `movs reg, imm` when assembling in Thumb-1 mode. Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
1 parent 342c259 commit 734fa18

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎arch/arm/core/cortex_m/thread.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -576,14 +576,14 @@ void arch_switch_to_main_thread(struct k_thread *main_thread, char *stack_ptr,
576576
"mov r4, %0\n" /* force _main to be stored in a register */
577577
"msr PSP, %1\n" /* __set_PSP(stack_ptr) */
578578

579-
"mov r0, #0\n" /* arch_irq_unlock(0) */
579+
"movs r0, #0\n" /* arch_irq_unlock(0) */
580580
"ldr r3, =arch_irq_unlock_outlined\n"
581581
"blx r3\n"
582582

583583
"mov r0, r4\n" /* z_thread_entry(_main, NULL, NULL, NULL) */
584-
"mov r1, #0\n"
585-
"mov r2, #0\n"
586-
"mov r3, #0\n"
584+
"movs r1, #0\n"
585+
"movs r2, #0\n"
586+
"movs r3, #0\n"
587587
"ldr r4, =z_thread_entry\n"
588588
"bx r4\n" /* We don’t intend to return, so there is no need to link. */
589589
:

0 commit comments

Comments
 (0)