65816-llvm-mos/demos/finishTest.c
Scott Duensing da095402ec Updated
2026-06-02 23:17:57 -05:00

25 lines
725 B
C

// finishTest.c - tiny standalone probe for mameDebug --finish.
// Calls a helper that does just enough work for the polling-based
// finish poller to install the return-PC bp before the helper returns.
// Writes a marker at 0x025000 from main() (after the helper returns)
// for additional verification. __attribute__((noinline)) so the
// helper isn't inlined under -O2.
static volatile int dummy = 0;
__attribute__((noinline))
int helper(int n) {
int i;
for (i = 0; i < n; i++) {
dummy += i;
}
return dummy;
}
int main(void) {
int r = helper(2000);
*(volatile unsigned int *)0x025000 = 0xC0DE;
*(volatile unsigned int *)0x025002 = (unsigned int)r;
while (1) { }
return 0;
}