Code: Select all
#include <stdio.h>
typedef unsigned long uint32;
typedef unsigned short addr16;
typedef unsigned short uint16;
typedef unsigned char uint8;
uint8* stack = 0;
addr16 stackTop = 0;
static uint32 stackPeek() {
uint8* location = stack + stackTop;
return *((uint32*)location);
}
static uint32 stackPop() {
uint32 value = stackPeek();
stackTop += 4;
return value;
}
void main() {
stackPop();
printf ("%x ", stackTop);
stackPop();
printf ("%x ", stackTop);
stackPop();
printf ("%x ", stackTop);
stackPop();
printf ("%x ", stackTop);
stackPop();
printf ("%x ", stackTop);
}
Code: Select all
zcc +zx -vn -clib=sdcc_iy -startup=0 Bug1.c -o bug -create-app
Note: using --max-allocs-per-node0 options fixes the problem