From 62019298b90742eab3c2c2970bfedfc9c45cb8f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Banaan=20Ananas?= Date: Mon, 15 Oct 2012 14:18:19 +0000 Subject: [PATCH] fixed H flag on SUB/SBB/CMP --- src/emu/cpu/i8085/i8085.c | 15 ++++++--------- src/emu/cpu/i8085/i8085cpu.h | 7 ++++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/emu/cpu/i8085/i8085.c b/src/emu/cpu/i8085/i8085.c index e1992c0b42d..404fca5db01 100644 --- a/src/emu/cpu/i8085/i8085.c +++ b/src/emu/cpu/i8085/i8085.c @@ -78,14 +78,12 @@ * Revisions: * * xx-xx-2002 Acho A. Tang - * * - 8085 emulation was in fact never used. It's been treated as a plain 8080. * - protected IRQ0 vector from being overwritten * - modified interrupt handler to properly process 8085-specific IRQ's * - corrected interrupt masking, RIM and SIM behaviors according to Intel's documentation * * 20-Jul-2002 Krzysztof Strzecha - * * - SBB r instructions should affect parity flag. * Fixed only for non x86 asm version (#define i8080_EXACT 1). * There are probably more opcodes which should affect this flag, but don't. @@ -98,30 +96,24 @@ * Thanks for the info go to Anton V. Ignatichev. * * 08-Dec-2002 Krzysztof Strzecha - * * - ADC r instructions should affect parity flag. * Fixed only for non x86 asm version (#define i8080_EXACT 1). * There are probably more opcodes which should affect this flag, but don't. * * 05-Sep-2003 Krzysztof Strzecha - * * - INR r, DCR r, ADD r, SUB r, CMP r instructions should affect parity flag. * Fixed only for non x86 asm version (#define i8080_EXACT 1). * * 23-Dec-2006 Tomasz Slanina - * * - SIM fixed * * 28-Jan-2007 Zsolt Vasvari - * * - Removed archaic i8080_EXACT flag. * * 08-June-2008 Miodrag Milanovic - * * - Flag setting fix for some instructions and cycle count update * * August 2009, hap - * * - removed DAA table * - fixed accidental double memory reads due to macro overuse * - fixed cycle deduction on unconditional CALL / RET @@ -133,10 +125,15 @@ * fixed X5 / V flags where accidentally broken due to flag names confusion * * 21-Aug-2009, Curt Coder - * * - added 8080A variant * - refactored callbacks to use devcb * + * October 2012, hap + * - fixed H flag on subtraction opcodes + * - on 8080, don't push the unsupported flags(X5, X3, V) to stack + * - 8080 passes on 8080/8085 CPU Exerciser, 8085 errors only on the DAA test + * (ref: http://www.idb.me.uk/sunhillow/8080.html - tests only 8080 opcodes) + * *****************************************************************************/ #include "emu.h" diff --git a/src/emu/cpu/i8085/i8085cpu.h b/src/emu/cpu/i8085/i8085cpu.h index db8611db4c3..bc4a5297082 100644 --- a/src/emu/cpu/i8085/i8085cpu.h +++ b/src/emu/cpu/i8085/i8085cpu.h @@ -85,19 +85,19 @@ #define M_SUB(R) { \ int q = cpustate->AF.b.h-R; \ - cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|((cpustate->AF.b.h^q^R)&HF)|VF; \ + cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|(~(cpustate->AF.b.h^q^R)&HF)|VF; \ cpustate->AF.b.h=q; \ } #define M_SBB(R) { \ int q = cpustate->AF.b.h-R-(cpustate->AF.b.l&CF); \ - cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|((cpustate->AF.b.h^q^R)&HF)|VF; \ + cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|(~(cpustate->AF.b.h^q^R)&HF)|VF; \ cpustate->AF.b.h=q; \ } #define M_CMP(R) { \ int q = cpustate->AF.b.h-R; \ - cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|((cpustate->AF.b.h^q^R)&HF)|VF; \ + cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|(~(cpustate->AF.b.h^q^R)&HF)|VF; \ } #define M_DAD(R) { \ @@ -106,6 +106,7 @@ cpustate->HL.w.l = q; \ } +// DSUB is 8085-only, not sure if H flag handling is correct #define M_DSUB(cpustate) { \ int q = cpustate->HL.b.l-cpustate->BC.b.l; \ cpustate->AF.b.l=ZS[q&255]|((q>>8)&CF)|VF| \