2021-05-27 06:06 AM
2021-05-27 10:36 AM
I think you can only access the PC register by it's address with the debug module, so not from within the application.
2021-05-27 10:43 AM
Call a function and return the return address...
2021-05-28 12:31 AM
Thanks DeLorean. How can I do that? Can you give a code example?
Best regards
Nikolay
2021-05-28 12:53 AM
Try it in STVD.
2021-05-29 06:32 AM
Hi MQi.1,
What do you mean? I use IAR Embedded Workbench for STM8 as IDE. I cannot switch to STVD. DeLoaren's answer looks great, but I don't know how manage to get the return address of the function.
Best regards
Nikolay
2021-05-29 09:47 AM
STM8 isn't my area
But ARM you have a subroutine like MOVS R0,LR ; BX LR, for x86 CALL $+x; POP EAX or POP EAX; JMP EAX type constructs.
2021-05-29 09:55 AM
If you have a basic understanding of the processor registers, the call stack, C calling/parameter passing model, some assembler. If you understand how the call works and pushes the return address, you should be able load it.
Look at a disassembly listing of an average app you should be able to pull a couple of nuggets.
You should be able to do a relative call and pop the return address, or call a fixed function that can retrieve a value out of a memory you can access.
2021-06-18 05:41 AM
You can use assemble index TRAP ; LDW X, SP ; LDW ($12, RAM), X ; the PC value is stored in RAM .