It is generally undefined what happens with local variables after you leave "main".
I would insert
C:
while(1);
at the end of the "main" and put a breakpoint in there.
I would also make sure that z is used somewhere, because otherwise it doesn't matter what value gets assigned to it, so the compiler could have optimized your manipulations away.[/CODE]
I would also make sure that z is used somewhere, because otherwise it doesn't matter what value gets assigned to it, so the compiler could have optimized your manipulations away.
An easy fix for this is to declare the variable volatile. On a PC you could just output it to the screen, but in a uC it can a bit harder to use a variable in a way that doesn't effect the operation of the code, but also can't be optimized out by the compiler. By marking it as volatile the compiler knows there is more to the variable than there appears and any code that references it will be run as written.