mirror of
https://github.com/mytechnotalent/Embedded-Hacking.git
synced 2026-04-01 17:10:20 +02:00
48 lines
1.5 KiB
ArmAsm
48 lines
1.5 KiB
ArmAsm
/**
|
|
* FILE: stack.s
|
|
*
|
|
* DESCRIPTION:
|
|
* RP2350 Stack Initialization.
|
|
*
|
|
* BRIEF:
|
|
* Provides stack pointer initialization for Main and Process Stack
|
|
* Pointers (MSP/PSP) and their limits.
|
|
*
|
|
* AUTHOR: Kevin Thomas
|
|
* CREATION DATE: November 27, 2025
|
|
* UPDATE DATE: November 27, 2025
|
|
*/
|
|
|
|
.syntax unified // use unified assembly syntax
|
|
.cpu cortex-m33 // target Cortex-M33 core
|
|
.thumb // use Thumb instruction set
|
|
|
|
.include "constants.s"
|
|
|
|
/**
|
|
* Initialize the .text section.
|
|
* The .text section contains executable code.
|
|
*/
|
|
.section .text // code section
|
|
.align 2 // align to 4-byte boundary
|
|
|
|
/**
|
|
* @brief Initialize stack pointers.
|
|
*
|
|
* @details Sets Main and Process Stack Pointers (MSP/PSP) and their limits.
|
|
*
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
.global Init_Stack
|
|
.type Init_Stack, %function
|
|
Init_Stack:
|
|
ldr r0, =STACK_TOP // load stack top
|
|
msr PSP, r0 // set PSP
|
|
ldr r0, =STACK_LIMIT // load stack limit
|
|
msr MSPLIM, r0 // set MSP limit
|
|
msr PSPLIM, r0 // set PSP limit
|
|
ldr r0, =STACK_TOP // reload stack top
|
|
msr MSP, r0 // set MSP
|
|
bx lr // return
|