Skip to content

Commit

Permalink
Cortex M3 MPS2: modernize assembler syntax and also add .ltorg (#1268)
Browse files Browse the repository at this point in the history
Cortex M3 MPS2: modernize assembler syntax and also add .ltorg

Signed-off-by: Florian La Roche <Florian.LaRoche@gmail.com>
  • Loading branch information
laroche authored Sep 25, 2024
1 parent 2067506 commit d80937d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
9 changes: 5 additions & 4 deletions FreeRTOS-Plus/Demo/FreeRTOS_Plus_TCP_Echo_Qemu_mps2/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,14 @@ void Default_Handler( void )
{
__asm volatile
(
"Default_Handler: \n"
" ldr r3, NVIC_INT_CTRL_CONST \n"
"Default_Handler:\n"
" ldr r3, =0xe000ed04\n"
" ldr r2, [r3, #0]\n"
" uxtb r2, r2\n"
"Infinite_Loop:\n"
" b Infinite_Loop\n"
".size Default_Handler, .-Default_Handler\n"
".align 4\n"
"NVIC_INT_CTRL_CONST: .word 0xe000ed04\n"
".ltorg\n"
);
}

Expand All @@ -135,6 +134,7 @@ void Default_Handler2( void )
" ldr r1, [r0, #24] \n"
" ldr r2, =prvGetRegistersFromStack \n"
" bx r2 \n"
" .ltorg \n"
);
}

Expand Down Expand Up @@ -219,6 +219,7 @@ __attribute__( ( naked ) ) void exit( int status )
"movs r0, #0x18\n" /* SYS_EXIT */
"bkpt 0xab\n"
"end: b end\n"
".ltorg"
);

( void ) status;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,12 @@ void Default_Handler( void )
__asm volatile
(
".align 8 \n"
" ldr r3, NVIC_INT_CTRL_CONST \n" /* Load the address of the interrupt control register into r3. */
" ldr r3, =0xe000ed04 \n" /* Load the address of the interrupt control register into r3. */
" ldr r2, [r3, #0] \n" /* Load the value of the interrupt control register into r2. */
" uxtb r2, r2 \n" /* The interrupt number is in the least significant byte - clear all other bits. */
"Infinite_Loop: \n" /* Sit in an infinite loop - the number of the executing interrupt is held in r2. */
" b Infinite_Loop \n"
".align 4 \n"
"NVIC_INT_CTRL_CONST: .word 0xe000ed04 \n"
" .ltorg \n"
);
}

Expand All @@ -144,6 +143,7 @@ void HardFault_Handler( void )
" ldr r1, [r0, #24] \n"
" ldr r2, =prvGetRegistersFromStack \n"
" bx r2 \n"
" .ltorg \n"
);
}

Expand Down
13 changes: 9 additions & 4 deletions FreeRTOS/Demo/CORTEX_MPU_M3_MPS2_QEMU_GCC/init/startup.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,14 @@ void Default_Handler( void )
{
__asm volatile
(
"Default_Handler: \n"
" ldr r3, NVIC_INT_CTRL_CONST \n"
"Default_Handler:\n"
" ldr r3, =0xe000ed04\n"
" ldr r2, [r3, #0]\n"
" uxtb r2, r2\n"
"Infinite_Loop:\n"
" b Infinite_Loop\n"
".size Default_Handler, .-Default_Handler\n"
".align 4\n"
"NVIC_INT_CTRL_CONST: .word 0xe000ed04\n"
".ltorg\n"
);
}

Expand All @@ -136,6 +135,7 @@ void HardFault_Handler( void )
" ldr r1, [r0, #24] \n"
" ldr r2, =prvGetRegistersFromStack \n"
" bx r2 \n"
" .ltorg \n"
);
}

Expand All @@ -150,6 +150,7 @@ void MemMang_Handler( void )
" mrsne r0, psp \n"
" ldr r1, =vHandleMemoryFault \n"
" bx r1 \n"
" .ltorg \n"
);
}

Expand All @@ -163,6 +164,7 @@ void BusFault_Handler( void )
" mrsne r0, psp \n"
" ldr r1, =vHandleMemoryFault \n"
" bx r1 \n"
" .ltorg \n"
);
}

Expand All @@ -176,6 +178,7 @@ void UsageFault_Handler( void )
" mrsne r0, psp \n"
" ldr r1, =vHandleMemoryFault \n"
" bx r1 \n"
" .ltorg \n"
);
}

Expand All @@ -189,6 +192,7 @@ void Debug_Handler( void )
" mrsne r0, psp \n"
" ldr r1, =vHandleMemoryFault \n"
" bx r1 \n"
" .ltorg \n"
);
}

Expand Down Expand Up @@ -246,6 +250,7 @@ void exit( int status )
"movs r0, #0x18\n" /* SYS_EXIT */
"bkpt 0xab\n"
"end: b end\n"
".ltorg\n"
);

( void ) status;
Expand Down

0 comments on commit d80937d

Please sign in to comment.