First, I would try to encode it so that for each of these flags there is only one producer and only one consumer. Then I cleared / set the flag only when it was needed. As for specifying a side effect, there should be a fairly standard header on top of the function, doxygen style:
// Function func // Does something // Consumes ready_flag and sets error_flag on error. int func() { if (ready_flag) { //do something then clear the flag if (some_error) error_flag = x; ready_flag = 0; } //don't mess with the flags outside of their 'scope' return 0; }
On the other hand, if the error and readiness flags are mutually exclusive, you can use the byte (or bits inside the byte / register) to indicate the readiness or status of the error.
0 for error, 1 for unprepared / error-free and 2 for finished / error-free (or -1, 0, 1, independently)
IIRC, the standard 8051 instruction set does not work with single bits, so using an integer byte for (different) flags should not produce huge results.
source share