From: Hugo Villeneuve Date: Sun, 17 Nov 2013 19:29:25 +0000 (-0500) Subject: Add carry bit definitions X-Git-Tag: v2.0.0~88 X-Git-Url: http://gitweb.hugovil.com/?a=commitdiff_plain;h=d1c1972f26e9eedcf02b56f10450bd1cb3c61d52;p=emu8051.git Add carry bit definitions --- diff --git a/src/psw.c b/src/psw.c index 2210d85..bf75854 100644 --- a/src/psw.c +++ b/src/psw.c @@ -28,9 +28,9 @@ psw_write_cy(int cy) 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 */ } @@ -40,7 +40,7 @@ psw_set_cy(void) { 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 */ } @@ -50,7 +50,7 @@ psw_clr_cy(void) { 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 */ } @@ -59,5 +59,5 @@ psw_clr_cy(void) int psw_read_cy(void) { - return memory_read8(INT_MEM_ID, _PSW_) >> 7; + return memory_read8(INT_MEM_ID, _PSW_) >> PSW_BIT_CY; } diff --git a/src/reg8051.h b/src/reg8051.h index 1800be7..b484246 100644 --- a/src/reg8051.h +++ b/src/reg8051.h @@ -62,4 +62,14 @@ #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 */