summaryrefslogtreecommitdiff
path: root/z80_decode.c
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2006-09-04 00:19:24 +0000
committerIan C <ianc@noddybox.co.uk>2006-09-04 00:19:24 +0000
commitcd09405e93abdb52507bd27e1ad4fa68b42b2c6b (patch)
tree15f7b2dd4ee45dd11f2739a9f680cdd12f4e0275 /z80_decode.c
parent324d0e882a41b3ebcd231790d45fc03f285a7a8b (diff)
ALU8 and ALU16 now validate against ZEXDOC.
Diffstat (limited to 'z80_decode.c')
-rw-r--r--z80_decode.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/z80_decode.c b/z80_decode.c
index 81760ae..036e34e 100644
--- a/z80_decode.c
+++ b/z80_decode.c
@@ -150,7 +150,7 @@ static Z80Word FPEEKW(Z80 *cpu, Z80Word addr)
*/
#define SWAP(A,B) \
do { \
- Z80Word swap_tmp; \
+ unsigned swap_tmp; \
swap_tmp=A; \
A=B; \
B=swap_tmp; \
@@ -162,11 +162,11 @@ do { \
#define ADD8(ONCE) \
do { \
Z80Byte VAL=ONCE; \
- Z80Word w; \
- w=cpu->AF.b[HI]+(Z80Word)VAL; \
+ unsigned w; \
+ w=cpu->AF.b[HI]+(unsigned)VAL; \
cpu->AF.b[LO]=SZtable[w]; \
if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI]^0x80)&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ if ((VAL^cpu->AF.b[HI]^0x80)&(VAL^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
SETHIDDEN(w); \
cpu->AF.b[HI]=w; \
} while(0)
@@ -175,11 +175,11 @@ do { \
#define ADC8(ONCE) \
do { \
Z80Byte VAL=ONCE; \
- Z80Word w; \
- w=(cpu->AF.b[HI]+(Z80Word)VAL+CARRY)&0x1ff; \
+ unsigned w; \
+ w=(cpu->AF.b[HI]+(unsigned)VAL+CARRY)&0x1ff; \
cpu->AF.b[LO]=SZtable[w]; \
if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI]^0x80)&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ if ((VAL^cpu->AF.b[HI]^0x80)&(VAL^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
SETHIDDEN(w); \
cpu->AF.b[HI]=w; \
} while(0)
@@ -188,11 +188,11 @@ do { \
#define SUB8(ONCE) \
do { \
Z80Byte VAL=ONCE; \
- Z80Word w; \
- w=(cpu->AF.b[HI]-(Z80Word)VAL)&0x1ff; \
+ unsigned w; \
+ w=(cpu->AF.b[HI]-(unsigned)VAL)&0x1ff; \
cpu->AF.b[LO]=SZtable[w]|N_Z80; \
if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI]^0x80)&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ if ((VAL^cpu->AF.b[HI])&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
SETHIDDEN(w); \
cpu->AF.b[HI]=w; \
} while(0)
@@ -201,11 +201,11 @@ do { \
#define CMP8(ONCE) \
do { \
Z80Byte VAL=ONCE; \
- Z80Word w; \
- w=(cpu->AF.b[HI]-(Z80Word)VAL)&0x1ff; \
+ unsigned w; \
+ w=(cpu->AF.b[HI]-(unsigned)VAL)&0x1ff; \
cpu->AF.b[LO]=SZtable[w]|N_Z80; \
if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI]^0x80)&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ if ((VAL^cpu->AF.b[HI])&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
SETHIDDEN(VAL); \
} while(0)
@@ -213,11 +213,11 @@ do { \
#define SBC8(ONCE) \
do { \
Z80Byte VAL=ONCE; \
- Z80Word w; \
- w=(cpu->AF.b[HI]-(Z80Word)VAL-CARRY)&0x1ff; \
+ unsigned w; \
+ w=(cpu->AF.b[HI]-(unsigned)VAL-CARRY)&0x1ff; \
cpu->AF.b[LO]=SZtable[w]|N_Z80; \
if ((cpu->AF.b[HI]^w^VAL)&H_Z80) cpu->AF.b[LO]|=H_Z80; \
- if ((VAL^cpu->AF.b[HI]^0x80)&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
+ if ((VAL^cpu->AF.b[HI])&(cpu->AF.b[HI]^w)&0x80) cpu->AF.b[LO]|=P_Z80; \
SETHIDDEN(w); \
cpu->AF.b[HI]=w; \
} while(0)
@@ -243,6 +243,7 @@ do { \
w=(REG)+(Z80Val)VAL+CARRY; \
cpu->AF.b[LO]=0; \
if ((w&0xffff)==0) cpu->AF.b[LO]=Z_Z80; \
+ if (w&0x8000) cpu->AF.b[LO]|=S_Z80; \
if (w>0xffff) cpu->AF.b[LO]|=C_Z80; \
if ((VAL^(REG)^0x8000)&((REG)^w)&0x8000) cpu->AF.b[LO]|=P_Z80; \
if (((REG)^w^VAL)&0x1000) cpu->AF.b[LO]|=H_Z80; \
@@ -257,11 +258,10 @@ do { \
Z80Val w; \
w=(REG)-(Z80Val)VAL-CARRY; \
cpu->AF.b[LO]=N_Z80; \
- if ((w&0xffff)==0) cpu->AF.b[LO]=Z_Z80; \
if (w&0x8000) cpu->AF.b[LO]|=S_Z80; \
if ((w&0xffff)==0) cpu->AF.b[LO]|=Z_Z80; \
if (w>0xffff) cpu->AF.b[LO]|=C_Z80; \
- if ((VAL^(REG))&(VAL^w)&0x8000) cpu->AF.b[LO]|=P_Z80; \
+ if ((VAL^(REG))&((REG)^w)&0x8000) cpu->AF.b[LO]|=P_Z80; \
if (((REG)^w^VAL)&0x1000) cpu->AF.b[LO]|=H_Z80; \
SETHIDDEN(w>>8); \
(REG)=w; \
@@ -442,8 +442,8 @@ do { \
else \
{ \
if (B==7) cpu->AF.b[LO]|=S_Z80; \
- if (B==5) cpu->AF.b[LO]|=B5_Z80; \
- if (B==3) cpu->AF.b[LO]|=B3_Z80; \
+ else if (B==5) cpu->AF.b[LO]|=B5_Z80; \
+ else if (B==3) cpu->AF.b[LO]|=B3_Z80; \
} \
} while(0)