I am trying to translate a C program. The destination language doesn't really matter, I am just trying to understand what every single part of the program is doing.
I cannot find any detail about:
while(variable); implements a spin-lock; i.e. this thread will remain at this statement until
variable is 0. I've introduced the term to help you search for a good technique in your new language.
It obviously burns the CPU, but can be quite an efficient way of doing this if only used for a few clock cycles. For it to work well,
variable needs to be qualified with
variable = variable ^ 0x800000; is an XOR operation, actually a single bit toggle in this case. (I would have preferred to see
variable ^= 0x800000 in multi-threaded code.) Its exact use is probably explainable from its context. Note that the arguments of the XOR are promoted to
int if they are smaller than that. It's doubtful that
variable^0x800000 is a 24 bit type unless
int is that size on your platform (unlikely but possible).