u_int8_t psw = memory_read8(INT_MEM_ID, _PSW_);
if (cy)
- psw |= 0x80; /* Set */
+ psw |= PSW_FLAG_CY; /* Set */
else
- psw &= ~0x80; /* Clear */
+ psw &= ~PSW_FLAG_CY; /* Clear */
memory_write8(INT_MEM_ID, _PSW_, psw); /* Save updated value */
}
{
u_int8_t psw = memory_read8(INT_MEM_ID, _PSW_);
- psw |= 0x80;
+ psw |= PSW_FLAG_CY;
memory_write8(INT_MEM_ID, _PSW_, psw); /* Save updated value */
}
{
u_int8_t psw = memory_read8(INT_MEM_ID, _PSW_);
- psw &= ~0x80;
+ psw &= ~PSW_FLAG_CY;
memory_write8(INT_MEM_ID, _PSW_, psw); /* Save updated value */
}
int
psw_read_cy(void)
{
- return memory_read8(INT_MEM_ID, _PSW_) >> 7;
+ return memory_read8(INT_MEM_ID, _PSW_) >> PSW_BIT_CY;
}
#define _BANK2_ 0x10
#define _BANK3_ 0x18
+#define PSW_BIT_CY 7
+#define PSW_BIT_AC 6
+#define PSW_BIT_OV 2
+#define PSW_BIT_P 0
+
+#define PSW_FLAG_CY (1 << PSW_BIT_CY)
+#define PSW_FLAG_AC (1 << PSW_BIT_AC)
+#define PSW_FLAG_OV (1 << PSW_BIT_OV)
+#define PSW_FLAG_P (1 << PSW_BIT_P)
+
#endif /* REG8051_H */