As the title suggests I'm having trouble with the stack seemingly getting trashed by the debugger. This happens with the built-in SofTec debugger of my DEMO9S12XSFAME board and a freshly installed Code Warrior 5.1.
More specifically it only happens with interrupts globally enabled in the MCU and the debugger set to ignore maskable interrupts.
Here's a repro case. Install it as the main file of a default 9S12XS128 C project, select the SofTec debugger, configure it to disable maskable ISR's, and try stepping through the loop.
#include "hidef.h"void failure(void *__far ptr, char stay) { volatile int dummy = (unsigned long) ptr >> 16; do ++dummy; while(stay); // Generated code: /* STAB 3,-SP <- Stores the argument at $20F4 LDX 7,SP LDAB 6,SP CLRA STD 1,SPloop: INCW 1,SP <- Trashes $20F4 w. $C4 LDAB 0,SP BNE loop LEAS 3,SP RTC */}void main(void) { EnableInterrupts; failure(NULL, 0);}