Previous 199869 Revisions Next

r18537 Monday 15th October, 2012 at 14:18:19 UTC by hap
fixed H flag on SUB/SBB/CMP
[src/emu/cpu/i8085]i8085.c i8085cpu.h

trunk/src/emu/cpu/i8085/i8085cpu.h
r18536r18537
8585
8686#define M_SUB(R) {                                                   \
8787   int q = cpustate->AF.b.h-R;                                          \
88   cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|((cpustate->AF.b.h^q^R)&HF)|VF;         \
88   cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|(~(cpustate->AF.b.h^q^R)&HF)|VF;      \
8989   cpustate->AF.b.h=q;                                                \
9090}
9191
9292#define M_SBB(R) {                                                   \
9393   int q = cpustate->AF.b.h-R-(cpustate->AF.b.l&CF);                        \
94   cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|((cpustate->AF.b.h^q^R)&HF)|VF;         \
94   cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|(~(cpustate->AF.b.h^q^R)&HF)|VF;      \
9595   cpustate->AF.b.h=q;                                                \
9696}
9797
9898#define M_CMP(R) {                                                   \
9999   int q = cpustate->AF.b.h-R;                                          \
100   cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|((cpustate->AF.b.h^q^R)&HF)|VF;         \
100   cpustate->AF.b.l=ZSP[q&255]|((q>>8)&CF)|(~(cpustate->AF.b.h^q^R)&HF)|VF;      \
101101}
102102
103103#define M_DAD(R) {                                                   \
r18536r18537
106106   cpustate->HL.w.l = q;                                             \
107107}
108108
109// DSUB is 8085-only, not sure if H flag handling is correct
109110#define M_DSUB(cpustate) {                                             \
110111   int q = cpustate->HL.b.l-cpustate->BC.b.l;                              \
111112   cpustate->AF.b.l=ZS[q&255]|((q>>8)&CF)|VF|                              \
trunk/src/emu/cpu/i8085/i8085.c
r18536r18537
7878 * Revisions:
7979 *
8080 * xx-xx-2002 Acho A. Tang
81 *
8281 * - 8085 emulation was in fact never used. It's been treated as a plain 8080.
8382 * - protected IRQ0 vector from being overwritten
8483 * - modified interrupt handler to properly process 8085-specific IRQ's
8584 * - corrected interrupt masking, RIM and SIM behaviors according to Intel's documentation
8685 *
8786 * 20-Jul-2002 Krzysztof Strzecha
88 *
8987 * - SBB r instructions should affect parity flag.
9088 *   Fixed only for non x86 asm version (#define i8080_EXACT 1).
9189 *   There are probably more opcodes which should affect this flag, but don't.
r18536r18537
9896 *   Thanks for the info go to Anton V. Ignatichev.
9997 *
10098 * 08-Dec-2002 Krzysztof Strzecha
101 *
10299 * - ADC r instructions should affect parity flag.
103100 *   Fixed only for non x86 asm version (#define i8080_EXACT 1).
104101 *   There are probably more opcodes which should affect this flag, but don't.
105102 *
106103 * 05-Sep-2003 Krzysztof Strzecha
107 *
108104 * - INR r, DCR r, ADD r, SUB r, CMP r instructions should affect parity flag.
109105 *   Fixed only for non x86 asm version (#define i8080_EXACT 1).
110106 *
111107 * 23-Dec-2006 Tomasz Slanina
112 *
113108 * - SIM fixed
114109 *
115110 * 28-Jan-2007 Zsolt Vasvari
116 *
117111 * - Removed archaic i8080_EXACT flag.
118112 *
119113 * 08-June-2008 Miodrag Milanovic
120 *
121114 * - Flag setting fix for some instructions and cycle count update
122115 *
123116 * August 2009, hap
124 *
125117 * - removed DAA table
126118 * - fixed accidental double memory reads due to macro overuse
127119 * - fixed cycle deduction on unconditional CALL / RET
r18536r18537
133125 *   fixed X5 / V flags where accidentally broken due to flag names confusion
134126 *
135127 * 21-Aug-2009, Curt Coder
136 *
137128 * - added 8080A variant
138129 * - refactored callbacks to use devcb
139130 *
131 * October 2012, hap
132 * - fixed H flag on subtraction opcodes
133 * - on 8080, don't push the unsupported flags(X5, X3, V) to stack
134 * - 8080 passes on 8080/8085 CPU Exerciser, 8085 errors only on the DAA test
135 *   (ref: http://www.idb.me.uk/sunhillow/8080.html - tests only 8080 opcodes)
136 *
140137 *****************************************************************************/
141138
142139#include "emu.h"

Previous 199869 Revisions Next


© 1997-2024 The MAME Team