1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-27 06:35:04 +00:00

Implemented IN[I/D]x. 18 failures remaining.

This commit is contained in:
Thomas Harte 2017-05-29 10:12:33 -04:00
parent c56a5344b9
commit ad56a9215c
2 changed files with 40 additions and 6 deletions

View File

@ -167,7 +167,7 @@ class FUSETests: XCTestCase {
let name = itemDictionary["name"] as! String
// if name != "edb1" {
// if name != "eda2" {
// continue;
// }
@ -194,7 +194,7 @@ class FUSETests: XCTestCase {
let finalState = RegisterState(machine: machine)
XCTAssertEqual(finalState, targetState, "Failed \(name)")
XCTAssert(finalState == targetState, "Failed \(name)")
// if finalState != targetState {
// failures = failures + 1
// if failures == 5 {

View File

@ -1076,8 +1076,8 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
#pragma mark - Repetition
#define REPEAT() \
if(parity_overflow_flag_) { \
#define REPEAT(test) \
if(test) { \
pc_.full -= 2; \
} else { \
move_to_next_program(); \
@ -1096,7 +1096,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
case MicroOp::LDDR:
case MicroOp::LDIR: {
LDxR_STEP(MicroOp::LDIR);
REPEAT();
REPEAT(bc_.full);
} break;
case MicroOp::LDD:
@ -1122,7 +1122,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
case MicroOp::CPDR:
case MicroOp::CPIR: {
CPxR_STEP(MicroOp::CPIR);
REPEAT();
REPEAT(bc_.full);
} break;
case MicroOp::CPD:
@ -1132,6 +1132,40 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
#undef CPxR_STEP
#define INxR_STEP(incr) \
bc_.bytes.high--; \
hl_.full += (operation->type == incr) ? 1 : -1; \
\
sign_result_ = zero_result_ = bit3_result_ = bit5_result_ = bc_.bytes.high; \
subtract_flag_ = (temp8_ >> 6) & Flag::Subtract; \
\
int next_bc = bc_.bytes.low + ((operation->type == incr) ? 1 : -1); \
int summation = temp8_ + (next_bc&0xff); \
\
if(summation > 0xff) { \
carry_flag_ = Flag::Carry; \
half_carry_flag_ = Flag::HalfCarry; \
} else { \
carry_flag_ = 0; \
half_carry_flag_ = 0; \
} \
\
summation = (summation&7) ^ bc_.bytes.high; \
set_parity(summation);
case MicroOp::INDR:
case MicroOp::INIR: {
INxR_STEP(MicroOp::INIR);
REPEAT(bc_.bytes.high);
} break;
case MicroOp::IND:
case MicroOp::INI: {
INxR_STEP(MicroOp::INI);
} break;
#undef INxR_STEP
#pragma mark - Bit Manipulation
case MicroOp::BIT: {