1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-05 10:28:58 +00:00

Corrects load and transfer flag oversights.

This commit is contained in:
Thomas Harte 2020-10-07 19:36:23 -04:00
parent 84c4fa197b
commit a4cec95db1
3 changed files with 17 additions and 4 deletions

View File

@ -44,7 +44,7 @@ class KlausDormannTests: XCTestCase {
switch address { switch address {
case 0x3399: return nil // success! case 0x3399: return nil // success!
case 0x052a: return "DEX did not correctly set zero flag" case 0x052a: return "TAX, DEX or LDA did not correctly set flags"
case 0x33a7: return "Decimal ADC result has wrong value" case 0x33a7: return "Decimal ADC result has wrong value"
case 0x3502: return "Binary SBC result has wrong value" case 0x3502: return "Binary SBC result has wrong value"
case 0x33b9: return "Decimal SBC result has wrong value" case 0x33b9: return "Decimal SBC result has wrong value"

View File

@ -313,27 +313,33 @@ template <typename BusHandler> void Processor<BusHandler>::run_for(const Cycles
case LDA: case LDA:
LD(a_, data_buffer_.value, m_masks_); LD(a_, data_buffer_.value, m_masks_);
flags_.set_nz(a_.full, m_shift_);
break; break;
case LDX: case LDX:
LD(x_, data_buffer_.value, x_masks_); LD(x_, data_buffer_.value, x_masks_);
flags_.set_nz(x_.full, x_shift_);
break; break;
case LDY: case LDY:
LD(y_, data_buffer_.value, x_masks_); LD(y_, data_buffer_.value, x_masks_);
flags_.set_nz(y_.full, x_shift_);
break; break;
case PLB: case PLB:
a_.halves.high = instruction_buffer_.value; data_bank_ = (instruction_buffer_.value & 0xff) << 16;
flags_.set_nz(instruction_buffer_.value);
break; break;
case PLD: case PLD:
direct_ = ((instruction_buffer_.value) & 0xff) << 16; direct_ = (instruction_buffer_.value & 0xff) << 16;
flags_.set_nz(instruction_buffer_.value);
break; break;
// The below attempts to obey the 8/16-bit mixed transfer rules // The below attempts to obey the 8/16-bit mixed transfer rules
// as documented in https://softpixel.com/~cwright/sianse/docs/65816NFO.HTM // as documented in https://softpixel.com/~cwright/sianse/docs/65816NFO.HTM
// (and makes reasonable guesses as to the N flag)
case TXS: case TXS:
s_ = x_.full & x_masks_[1]; s_ = x_.full & x_masks_[1];
@ -341,30 +347,37 @@ template <typename BusHandler> void Processor<BusHandler>::run_for(const Cycles
case TSX: case TSX:
LD(x_, s_.full, x_masks_); LD(x_, s_.full, x_masks_);
flags_.set_nz(x_.full, x_shift_);
break; break;
case TXY: case TXY:
LD(y_, x_.full, x_masks_); LD(y_, x_.full, x_masks_);
flags_.set_nz(y_.full, x_shift_);
break; break;
case TYX: case TYX:
LD(x_, y_.full, x_masks_); LD(x_, y_.full, x_masks_);
flags_.set_nz(x_.full, x_shift_);
break; break;
case TAX: case TAX:
LD(x_, a_.full, x_masks_); LD(x_, a_.full, x_masks_);
flags_.set_nz(x_.full, x_shift_);
break; break;
case TAY: case TAY:
LD(x_, a_.full, x_masks_); LD(x_, a_.full, x_masks_);
flags_.set_nz(y_.full, x_shift_);
break; break;
case TXA: case TXA:
LD(a_, x_.full, m_masks_); LD(a_, x_.full, m_masks_);
flags_.set_nz(a_.full, m_shift_);
break; break;
case TYA: case TYA:
LD(a_, y_.full, m_masks_); LD(a_, y_.full, m_masks_);
flags_.set_nz(a_.full, m_shift_);
break; break;

View File

@ -893,7 +893,7 @@ ProcessorStorage::ProcessorStorage() {
/* 0xa8 TAY i */ op(implied, TAY); /* 0xa8 TAY i */ op(implied, TAY);
/* 0xa9 LDA # */ op(immediate, LDA); /* 0xa9 LDA # */ op(immediate, LDA);
/* 0xaa TAX i */ op(implied, TAX); /* 0xaa TAX i */ op(implied, TAX);
/* 0xab PLB s */ op(stack_pull, PLB); /* 0xab PLB s */ op(stack_pull, PLB); // TODO: force to 8-bit only; ditto [at least] PHB, PLD, PHD.
/* 0xac LDY a */ op(absolute, LDY); /* 0xac LDY a */ op(absolute, LDY);
/* 0xad LDA a */ op(absolute, LDA); /* 0xad LDA a */ op(absolute, LDA);
/* 0xae LDX a */ op(absolute, LDX); /* 0xae LDX a */ op(absolute, LDX);