??? 04/21/07 02:41 Modified: 04/21/07 03:51 Read: times |
#137683 - Bit test and clear Responding to: ???'s previous message |
I think that the problem you had can be accurately described as one of atomicity (or lack thereof). Some processors have an instruction that will test and clear a bit in a single, uninterruptable (i.e., atomic) step. Such instructions are designed specifically to address the problem you encountered. This page describes some in the Motorola 68000 and Intel 80x86 instruction sets.
Closer to home, the 8051 offers JBC instruction, which is exactly what you would have used if you were coding in assembly language. The question now is, are there any tricks you can play with your C compiler to make it generate JBC when you need it? If you're using the Keil compiler, it looks like the answer is yes. -- Russ |
Topic | Author | Date |
lesson learned | 01/01/70 00:00 | |
"atomic" | 01/01/70 00:00 | |
atomicity | 01/01/70 00:00 | |
if thatb is so | 01/01/70 00:00 | |
Indeed | 01/01/70 00:00 | |
Bit test and clear | 01/01/70 00:00 | |
JBC | 01/01/70 00:00 | |
favourite atomic test-and-set instructions | 01/01/70 00:00 | |
SDCC also | 01/01/70 00:00 | |
Classic atomic problem | 01/01/70 00:00 | |
and/or ... | 01/01/70 00:00 | |
another example![]() | 01/01/70 00:00 |