-extern inline void bset(void* addr, u8 mask) {
- asm volatile (
- "ldx %0\n"
- "bset 00,x,%1"
- : /* outputs */
- : "p" (addr), "g" (mask) /* inputs */
- : "x" /* altered registers */
- );
+extern inline void bset(const void* addr, const u8 mask) {
+ /* The assembly breaks when gcc tries to optimise consecutive calls to
+ * bset/bclr on the same memory address. Sigh. Either turn off optimisation
+ * (-O1 without -Os works), or we do it the dumb way.
+ */
+ *(u8*)addr |= mask;
+ // asm volatile (
+ // "ldx %0\n"
+ // "bset 00,x,%1"
+ // : /* outputs */
+ // : "p" (addr), "g" (mask) /* inputs */
+ // : "x" /* altered registers */
+ // );