Reworking of the assembly
[uccvend-snackrom.git] / ROM2 / asm.h
index 0c9b7fa..3e8cc09 100644 (file)
@@ -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_ */

UCC git Repository :: git.ucc.asn.au