Hi all,

Can anybody tell me how stack pointer wrapping is handled in ucSim's STM8 simulation? Specifically, I'm wondering whether it correctly obeys the SP limitations according to the specific MCU model being simulated.

As far as I understand things, the SP cannot traverse the entire RAM space - i.e. it cannot decrement all the way down to 0x0000. And, different models have different SP limits - as described in their datasheets. For example, on the STM8S003, the stack is limited to 513 bytes (out of a total of 1KB RAM), and the SP will wrap below 0x1FF back to 0x3FF. Similarly, on the STM8S208, stack is limited to 1024 bytes (out of 6KB RAM), and will wrap at 0x13FF back to 0x17FF.

Does ucSim simulate this accurately?

I tried to look at the ucSim source to find out, but I am having a difficult time comprehending it. Best I can deduce is that the push1/push2 and pop1/pop2 macros (in stm8mac.h) appear to simply decrement/increment in an unbounded manner, and may not implement any SP wrapping.

Regards,
Basil Hussain


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

Reply via email to