On 21/04/2022 16:20, Mike Jagdis via Sdcc-user wrote:
Start within the 0x3ff..0x1ff region and the stack
wraps around. Start outside that and... well... you can have... fun...?

I found the following article in which the author finds through some experimentation that - at least for the STM8S103 - if the stack pointer is manually initialised to a value outside the 0x1FF-0x3FF area, then push/pop will decrement/increment perfectly happily. However, when the register value wraps around at 0x0, it is not to ram end, but to 0xFFFF.

https://sudonull.com/post/13801-Break-STM8-stack

I mean, I guess it's not surprising seeing as RM0016 talks in section 3.1.2 about the possibility to implement a custom stack model outside the normal area, which wouldn't be possible if the above behaviour didn't occur.

I_think_  the non-rollover parts just let you do your own thing (maybe
there's still a comparator that triggers an overflow event though?)

Maybe when RM0016 says "The stack roll-over limit is not implemented on all devices", they actually mean that "a limit does not exist", rather than "a limit exists, but does not automatically roll over". Because, I guess, thinking about it, what would be the point of the latter?

Regards,
Basil Hussain


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to