It's always safe for 256 bytes because processors only have two choices
1.) Single opcode that does a direct memory increment (Irq can't catch it)
2.) Lift the value to a register, increment it and store it back. The irq can catch it but
it reads the last value at the memory location which is still valid.
I will also give you a way you could have fixed your code so it always go route 2, if you need to do this in future ... using volatile to a different end
How this works is postfix is a char on the local stack and I have told it that it is volatile.
So the first line must execute as is and be written to that position on the stack.
Then after I have used the current value I simply transfer the postfix value.
I have given the compiler and optimizer no wiggle room for what I want it to do.
volatile char postfix = (comin_rptr + 1) & BUFFER_MASK;
char temp; //temp scratch
if (comin_wptr == comin_rptr)
return 0; //if we are called when there is nothing ready
temp = comin_buf[comin_rptr]; //fetch character from buffer, and bump read pointer
comin_rptr = postfix; // store the postfix value
return temp; //return the value we read from the buffer