I am currently trying to write startup code in assembly for an STM8 without any vendor libraries. More specifically, I am using an STM8S103f3p6. I am still inexperienced in assembly and with startup code, but I am confident to know what has to be done at the start of a µC. But apparently I don't know, HOW it is done.
For assembly, I am currently using the STM8-AS which is based on GNU AS. At the very start of my reset_handler, I want to set the stack pointer to the end of RAM 0x0003FF like shown in the datasheet (direct download). But the reference manual states that the stack pointer (SPH and SPL) can not be accessed by memory access instructions. But setting the SP in debug mode can't be correct, can it? I am unsure what to make of that

STM8 Assembly startup code: Access Core registers to initialize stack pointer
103 Views Asked by Alex At
1
There are 1 best solutions below
Related Questions in STARTUP
- How to open all folders in CWD as tmux windows
- Anaconda navigator does not start every time my laptop is turned off
- setting guifont in .vimrc does not work Windows 11
- For a two-stage cluster deployed in Apache IoTDB, why the confignode of the second server cannot be started and added to the seed confignode?
- Fresh MongoDB Community Edition install will not start (Installed through a fresh Homebrew install)
- How to deal with the status of the third confignode in Apache IoTDB cluster to running?
- warning: no previous extern declaration for non-static variable 'c' [-Wmissing-variable-declarations]
- I created an executable in Python but it doesn't always start properly at startup
- Adding multiple OpenIdConnect authentication schemes to the services and choosing at runtime which to use
- Portable windows app built with electron-builder takes too long to start up
- Is there a way to remove UWP startup tasks entries from the Task Manager?
- Intelhaxm has made iMac unable to start up
- Unable to start debugging. Visual Studio 2022
- Flutter app performs downloads and tasks on startup without user interaction
- PowerShell to start a script at startup with Task Scheduler
Related Questions in STACK-POINTER
- Using end of memory address as process stack pointer value causing INVPC hard fault
- How Stack is filled and how ESP behaves during stack overflow exploitation
- Clang ignores -mstack-alignment=XX flag
- Cortex M4 stacking and unstacking with a diferent stack pointer
- I can't use RSP to reference the end of the stack
- STM8 Assembly startup code: Access Core registers to initialize stack pointer
- Frame, Stack Frame in process Stacking Unstacking
- Stack pointer add on loop
- STM32 and SP value at startup: should the reset handler set SP manually?
- What happens in the CPU if I pop / push all the stack?
- Can I get %rsp with inline assembly?
- Storing and Loading $ra
- What is the RUST equivalent of following C code?
- What is the benefit of having a dedicated stack pointer register?
- How stack memory works when pushing value to it on x86_64?
Related Questions in SDCC
- SDCC dependency generation
- Makefile: no rule to make target (sdcc)
- STM8 Assembly startup code: Access Core registers to initialize stack pointer
- sdcc code location - how to get file without padding when using start address greater than zero
- Is this a possible bug in SDCC?
- SDCC assign memory address to pointer, no effect
- SDCC produces elf output with sections of NULL type
- Binary Injection into ELF File
- sdcc compiler wrong machine code generation
- MCU 8051 IDE with SDCC stuck at compiling
- SDCC compile warning 88: cast of LITERAL value to 'generic' pointer
- VScode: Disable syntax highlighting for a range of lines
- Use Makefile and sdcc to build a perfect automation for MCS-51 development
- Can not create 8051 project in Eclipse on Mac
- With SDCC, how to access word pointer from another file
Related Questions in STM8
- Unmasking SPI Interrupt for both TXE and RXNE on STM8S105
- How to import STM8S/A Standard peripheral library in a STM8 project (ST Visual Develop)?
- Evaluation if conditional statement on ST Visual Developer with Cosmic for STM8
- Stm8l mcu RTC calibration problem using RTC_SmoothCalibConfig()
- STM8 Assembly startup code: Access Core registers to initialize stack pointer
- stm8s003 timer1 channel2 capture doesn't work
- Will IAR complier optimization causing trouble on code running?
- Stm8 Option Byte Programming
- stm8s003f3 tim2 configuration
- Stm8 assembly instructions
- How to configurate an external ADC chip in conjunction with stm 8
- How can I Initialize TIM1 as Capture Interrupt at Channel 4 for CD4060 Pressure Sensor using STM8?
- Unable to send data with I2C using STM8s in C [Solved]
- is there a HAL_SPI_transmit function in stm8?
- SPI communication on STM8 controller doesn't work
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
According to the data sheet table 9, the SP holds 0x03FF on reset. So you don't need to set it explicitly in this case. The programming manual says the same in chapter 3.2:
However, if you want to load a value into the SP, you can use only one of these instructions according to the programming manual (chapter 7.4 on
LDW):LDW SP, XLDW SP, YThe registers
XandYcan be loaded before with immediate values, for exampleLDW Y, #$03FF.The complete sequence with
Yis: