mirror of https://github.com/stella-emu/stella.git
Fixed bug with SBC opcode in decimal/BCD mode, similar to the previously
fixed ADC issue. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1404 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
0c15f5daeb
commit
360a5711ed
|
@ -13,14 +13,14 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: M6502.m4,v 1.5 2008-02-23 16:26:29 stephena Exp $
|
// $Id: M6502.m4,v 1.6 2008-02-23 20:06:36 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Code and cases to emulate each of the 6502 instruction
|
Code and cases to emulate each of the 6502 instruction
|
||||||
|
|
||||||
@author Bradford W. Mott
|
@author Bradford W. Mott
|
||||||
@version $Id: M6502.m4,v 1.5 2008-02-23 16:26:29 stephena Exp $
|
@version $Id: M6502.m4,v 1.6 2008-02-23 20:06:36 stephena Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTSAMEPAGE
|
#ifndef NOTSAMEPAGE
|
||||||
|
@ -545,8 +545,9 @@ define(M6502_SBC, `{
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: M6502Hi.ins,v 1.3 2008-02-23 16:26:29 stephena Exp $
|
// $Id: M6502Hi.ins,v 1.4 2008-02-23 20:06:37 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
high compatibility emulation
|
high compatibility emulation
|
||||||
|
|
||||||
@author Bradford W. Mott
|
@author Bradford W. Mott
|
||||||
@version $Id: M6502Hi.ins,v 1.3 2008-02-23 16:26:29 stephena Exp $
|
@version $Id: M6502Hi.ins,v 1.4 2008-02-23 20:06:37 stephena Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTSAMEPAGE
|
#ifndef NOTSAMEPAGE
|
||||||
|
@ -114,14 +114,14 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: M6502Hi.ins,v 1.3 2008-02-23 16:26:29 stephena Exp $
|
// $Id: M6502Hi.ins,v 1.4 2008-02-23 20:06:37 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Code and cases to emulate each of the 6502 instruction
|
Code and cases to emulate each of the 6502 instruction
|
||||||
|
|
||||||
@author Bradford W. Mott
|
@author Bradford W. Mott
|
||||||
@version $Id: M6502Hi.ins,v 1.3 2008-02-23 16:26:29 stephena Exp $
|
@version $Id: M6502Hi.ins,v 1.4 2008-02-23 20:06:37 stephena Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTSAMEPAGE
|
#ifndef NOTSAMEPAGE
|
||||||
|
@ -3501,8 +3501,9 @@ case 0xeb:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3538,8 +3539,9 @@ case 0xe5:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3578,8 +3580,9 @@ case 0xf5:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3617,8 +3620,9 @@ case 0xed:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3658,8 +3662,9 @@ case 0xfd:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3699,8 +3704,9 @@ case 0xf9:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3741,8 +3747,9 @@ case 0xe1:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3783,8 +3790,9 @@ case 0xf1:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: M6502Low.ins,v 1.5 2008-02-23 16:26:29 stephena Exp $
|
// $Id: M6502Low.ins,v 1.6 2008-02-23 20:06:37 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
low compatibility emulation
|
low compatibility emulation
|
||||||
|
|
||||||
@author Bradford W. Mott
|
@author Bradford W. Mott
|
||||||
@version $Id: M6502Low.ins,v 1.5 2008-02-23 16:26:29 stephena Exp $
|
@version $Id: M6502Low.ins,v 1.6 2008-02-23 20:06:37 stephena Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTSAMEPAGE
|
#ifndef NOTSAMEPAGE
|
||||||
|
@ -115,14 +115,14 @@
|
||||||
// See the file "license" for information on usage and redistribution of
|
// See the file "license" for information on usage and redistribution of
|
||||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||||
//
|
//
|
||||||
// $Id: M6502Low.ins,v 1.5 2008-02-23 16:26:29 stephena Exp $
|
// $Id: M6502Low.ins,v 1.6 2008-02-23 20:06:37 stephena Exp $
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Code and cases to emulate each of the 6502 instruction
|
Code and cases to emulate each of the 6502 instruction
|
||||||
|
|
||||||
@author Bradford W. Mott
|
@author Bradford W. Mott
|
||||||
@version $Id: M6502Low.ins,v 1.5 2008-02-23 16:26:29 stephena Exp $
|
@version $Id: M6502Low.ins,v 1.6 2008-02-23 20:06:37 stephena Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef NOTSAMEPAGE
|
#ifndef NOTSAMEPAGE
|
||||||
|
@ -3490,8 +3490,9 @@ case 0xeb:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3528,8 +3529,9 @@ case 0xe5:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3566,8 +3568,9 @@ case 0xf5:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3605,8 +3608,9 @@ case 0xed:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3652,8 +3656,9 @@ case 0xfd:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3699,8 +3704,9 @@ case 0xf9:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3738,8 +3744,9 @@ case 0xe1:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
@ -3784,8 +3791,9 @@ case 0xf1:
|
||||||
if(difference < 0)
|
if(difference < 0)
|
||||||
difference += 100;
|
difference += 100;
|
||||||
|
|
||||||
|
// Z flag calculation ignores D flag
|
||||||
|
notZ = (((Int16)A) + ((Int16)~operand) + (C ? 1 : 0)) && 0xff;
|
||||||
A = ourBCDTable[1][difference];
|
A = ourBCDTable[1][difference];
|
||||||
notZ = A;
|
|
||||||
N = A & 0x80;
|
N = A & 0x80;
|
||||||
|
|
||||||
C = (oldA >= (operand + (C ? 0 : 1)));
|
C = (oldA >= (operand + (C ? 0 : 1)));
|
||||||
|
|
Loading…
Reference in New Issue