X-Git-Url: https://git.ucc.asn.au/?p=uccvend-snackrom.git;a=blobdiff_plain;f=ROM2%2Fasm.h;h=3e8cc09491c30cfd104a2018e27751882404be46;hp=0c9b7fa776c8217d97255a6a1b51ed34d6943470;hb=cef1445c4f1ebaa38f9e6561b4fd15f164a27dcd;hpb=c9763dcb182398266bae1c6a7a848beec1cba35d diff --git a/ROM2/asm.h b/ROM2/asm.h index 0c9b7fa..3e8cc09 100644 --- a/ROM2/asm.h +++ b/ROM2/asm.h @@ -3,25 +3,28 @@ #include "types.h" -/* these would be inline functions, but gcc won't believe that mask is a constant - * when passed as a parameter +/* The "g" below really should be an "i", but gcc doesn't believe that it will + * always be an immediate value. Using "g" makes the compiler be quiet, but + * the assembler will fail if the value is not an immediate. */ -#define bset(addr, mask) \ - asm volatile ( \ - "ldx %0\n" \ - "bset 00,x,%1" \ - : /* outputs */ \ - : "p" (addr), "i" (mask) /* inputs */ \ - : "x" /* altered registers */ \ +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 */ ); +} -#define bclr(addr, mask) \ - asm volatile ( \ - "ldx %0\n" \ - "bclr 00,x,%1" \ - : /* outputs */ \ - : "p" (addr), "i" (mask) /* inputs */ \ - : "x" /* altered registers */ \ +extern inline void bclr(void* addr, u8 mask) { + asm volatile ( + "ldx %0\n" + "bclr 00,x,%1" + : /* outputs */ + : "p" (addr), "g" (mask) /* inputs */ + : "x" /* altered registers */ ); +} #endif /* _ASM_H_ */