From: kub Date: Mon, 25 Oct 2021 17:22:51 +0000 (+0200) Subject: z80, fix for cz80 handling of A register X-Git-Tag: v2.00~446 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0be9a92e7783b06601632b3a9932a68c5323d847;p=picodrive.git z80, fix for cz80 handling of A register --- diff --git a/cpu/cz80/cz80.c b/cpu/cz80/cz80.c index 41d58199..888478ef 100644 --- a/cpu/cz80/cz80.c +++ b/cpu/cz80/cz80.c @@ -196,7 +196,7 @@ void Cz80_Init(cz80_struc *CPU) CPU->pzR16[0] = pzBC; CPU->pzR16[1] = pzDE; CPU->pzR16[2] = pzHL; - CPU->pzR16[3] = pzAF; + CPU->pzR16[3] = pzFA; zIX = zIY = 0xffff; @@ -339,13 +339,13 @@ UINT32 Cz80_Get_Reg(cz80_struc *CPU, INT32 regnum) { case CZ80_PC: return (CPU->PC - CPU->BasePC); case CZ80_SP: return zSP; - case CZ80_AF: return zAF; + case CZ80_FA: return zFA; case CZ80_BC: return zBC; case CZ80_DE: return zDE; case CZ80_HL: return zHL; case CZ80_IX: return zIX; case CZ80_IY: return zIY; - case CZ80_AF2: return zAF2; + case CZ80_FA2: return zFA2; case CZ80_BC2: return zBC2; case CZ80_DE2: return zDE2; case CZ80_HL2: return zHL2; @@ -378,13 +378,13 @@ void Cz80_Set_Reg(cz80_struc *CPU, INT32 regnum, UINT32 val) break; case CZ80_SP: zSP = val; break; - case CZ80_AF: zAF = val; break; + case CZ80_FA: zFA = val; break; case CZ80_BC: zBC = val; break; case CZ80_DE: zDE = val; break; case CZ80_HL: zHL = val; break; case CZ80_IX: zIX = val; break; case CZ80_IY: zIY = val; break; - case CZ80_AF2: zAF2 = val; break; + case CZ80_FA2: zFA2 = val; break; case CZ80_BC2: zBC2 = val; break; case CZ80_DE2: zDE2 = val; break; case CZ80_HL2: zHL2 = val; break; diff --git a/cpu/cz80/cz80.h b/cpu/cz80/cz80.h index a49d1f18..894ef5c3 100644 --- a/cpu/cz80/cz80.h +++ b/cpu/cz80/cz80.h @@ -79,12 +79,12 @@ extern "C" { #define zR8(A) (*CPU->pzR8[A]) #define zR16(A) (CPU->pzR16[A]->W) -#define pzAF &(CPU->AF) -#define zAF CPU->AF.W -#define zlAF CPU->AF.B.L -#define zhAF CPU->AF.B.H -#define zA zhAF -#define zF zlAF +#define pzFA &(CPU->FA) +#define zFA CPU->FA.W +#define zlFA CPU->FA.B.L +#define zhFA CPU->FA.B.H +#define zA zlFA +#define zF zhFA #define pzBC &(CPU->BC) #define zBC CPU->BC.W @@ -107,11 +107,11 @@ extern "C" { #define zH zhHL #define zL zlHL -#define zAF2 CPU->AF2.W -#define zlAF2 CPU->AF2.B.L -#define zhAF2 CPU->AF2.B.H -#define zA2 zhAF2 -#define zF2 zlAF2 +#define zFA2 CPU->FA2.W +#define zlFA2 CPU->FA2.B.L +#define zhFA2 CPU->FA2.B.H +#define zA2 zhFA2 +#define zF2 zlFA2 #define zBC2 CPU->BC2.W #define zDE2 CPU->DE2.W @@ -187,13 +187,13 @@ enum { CZ80_PC = 1, CZ80_SP, - CZ80_AF, + CZ80_FA, CZ80_BC, CZ80_DE, CZ80_HL, CZ80_IX, CZ80_IY, - CZ80_AF2, + CZ80_FA2, CZ80_BC2, CZ80_DE2, CZ80_HL2, @@ -232,7 +232,7 @@ typedef struct cz80_t union16 BC; union16 DE; union16 HL; - union16 AF; + union16 FA; }; }; @@ -244,7 +244,7 @@ typedef struct cz80_t union16 BC2; union16 DE2; union16 HL2; - union16 AF2; + union16 FA2; union16 R; union16 IFF; diff --git a/cpu/cz80/cz80_op.c b/cpu/cz80/cz80_op.c index a46210e6..cf3062e2 100644 --- a/cpu/cz80/cz80_op.c +++ b/cpu/cz80/cz80_op.c @@ -200,9 +200,15 @@ OP_LD_mNN_xx: POP -----------------------------------------*/ + OP(0xf1): // POP AF +OP_POP_AF: + POP_16(res) + zA = res >> 8; + zF = res & 0xFF; + RET(10) + OP(0xc1): // POP BC OP(0xd1): // POP DE - OP(0xf1): // POP AF OP_POP_RR: data = CPU->pzR16[(Opcode >> 4) & 3]; @@ -215,9 +221,14 @@ OP_POP: PUSH -----------------------------------------*/ + OP(0xf5): // PUSH AF +OP_PUSH_AF: + PUSH_16((zA << 8) | zF); + RET(11) + + OP(0xc5): // PUSH BC OP(0xd5): // PUSH DE - OP(0xf5): // PUSH AF OP_PUSH_RR: data = CPU->pzR16[(Opcode >> 4) & 3]; @@ -232,9 +243,9 @@ OP_PUSH: OP(0x08): // EX AF,AF' OP_EX_AF_AF2: - res = zAF; - zAF = zAF2; - zAF2 = res; + res = zFA; + zFA = zFA2; + zFA2 = res; RET(4) OP(0xeb): // EX DE,HL diff --git a/cpu/cz80/cz80_opXY.c b/cpu/cz80/cz80_opXY.c index b02e4011..a73c3fc9 100644 --- a/cpu/cz80/cz80_opXY.c +++ b/cpu/cz80/cz80_opXY.c @@ -194,8 +194,9 @@ switch (Opcode) OPXY(0xc1): // POP BC OPXY(0xd1): // POP DE - OPXY(0xf1): // POP AF goto OP_POP_RR; + OPXY(0xf1): // POP AF + goto OP_POP_AF; OPXY(0xe1): // POP IX goto OP_POP; @@ -206,8 +207,9 @@ switch (Opcode) OPXY(0xc5): // PUSH BC OPXY(0xd5): // PUSH DE - OPXY(0xf5): // PUSH AF goto OP_PUSH_RR; + OPXY(0xf5): // PUSH AF + goto OP_PUSH_AF; OPXY(0xe5): // PUSH IX goto OP_PUSH;