1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-24 12:30:17 +00:00

Continued cleaning efforts, added conditional RET.

This commit is contained in:
Thomas Harte 2017-05-21 10:13:59 -04:00
parent e92d936ce8
commit e48ee16366

View File

@ -172,6 +172,7 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
#define JP(cc) Program(FETCH16(temp16_, pc_), {MicroOp::cc}, {MicroOp::Move16, &temp16_.full, &pc_.full})
#define CALL(cc) Program(FETCH16(temp16_, pc_), {MicroOp::cc}, WAIT(1), PUSH(pc_), {MicroOp::Move16, &temp16_.full, &pc_.full})
#define RET(cc) Program(WAIT(1), {MicroOp::cc}, POP(pc_))
#define LD(a, b) Program({MicroOp::Move8, &b, &a})
#define LD_GROUP(r) \
@ -351,70 +352,46 @@ template <class T> class Processor: public MicroOpScheduler<MicroOp> {
/* 0xb8 CP B; 0xb9 CP C; 0xba CP D; 0xbb CP E; 0xbc CP H; 0xbd CP L; 0xbe CP (HL); 0xbf CP A */
OP_GROUP(CP8),
XX, /* 0xc0 RET NZ */
Program(POP(bc_)), /* 0xc1 POP BC */
JP(TestNZ), /* 0xc2 JP NZ */
Program(FETCH16L(temp16_, pc_), {MicroOp::Move16, &temp16_.full, &pc_.full}), /* 0xc3 JP nn */
CALL(TestNZ), /* 0xc4 CALL NZ */
Program(WAIT(1), PUSH(bc_)), /* 0xc5 PUSH BC */
Program(FETCH(temp8_, pc_), {MicroOp::ADD8, &temp8_}), /* 0xc6 ADD A, n */
XX, /* 0xc7 RST 00h */
XX, /* 0xc8 RET Z */
Program(POP(pc_)), /* 0xc9 RET */
JP(TestZ), /* 0xca JP Z */
XX, /* 0xcb [CB page] */
CALL(TestZ), /* 0xcc CALL Z */
Program(FETCH16(temp16_, pc_), WAIT(1), PUSH(pc_), {MicroOp::Move16, &temp16_.full, &pc_.full}), /* 0xcd CALL */
Program(FETCH(temp8_, pc_), {MicroOp::ADC8, &temp8_}), /* 0xce ADC A, n */
XX, /* 0xcf RST 08h */
XX, /* 0xd0 RET NC */
Program(POP(de_)), /* 0xd1 POP DE */
JP(TestNC), /* 0xd2 JP NC */
XX, /* 0xd3 OUT (n), A */
CALL(TestNC), /* 0xd4 CALL NC */
Program(WAIT(1), PUSH(de_)), /* 0xd5 PUSH DE */
Program(FETCH(temp8_, pc_), {MicroOp::SUB8, &temp8_}), /* 0xd6 SUB n */
XX, /* 0xd7 RST 10h */
XX, /* 0xd8 RET C */
XX, /* 0xd9 EXX */
JP(TestC), /* 0xda JP C */
XX, /* 0xdb IN A, (n) */
CALL(TestC), /* 0xdc CALL C */
XX, /* 0xdd [DD page] */
Program(FETCH(temp8_, pc_), {MicroOp::SBC8, &temp8_}), /* 0xde SBC A, n */
XX, /* 0xdf RST 18h */
XX, /* 0xe0 RET PO */
Program(POP(hl_)), /* 0xe1 POP HL */
JP(TestPO), /* 0xe2 JP PO */
XX, /* 0xe3 EX (SP), HL */
CALL(TestPO), /* 0xe4 CALL PO */
Program(WAIT(1), PUSH(hl_)), /* 0xe5 PUSH HL */
Program(FETCH(temp8_, pc_), {MicroOp::And, &temp8_}), /* 0xe6 AND n */
XX, /* 0xe7 RST 20h */
XX, /* 0xe8 RET PE */
XX, /* 0xe9 JP (HL) */
JP(TestPE), /* 0xea JP PE */
Program({MicroOp::ExDEHL}), /* 0xeb EX DE, HL */
CALL(TestPE), /* 0xec CALL PE */
Program({MicroOp::SetInstructionPage, ed_page_}), /* 0xed [ED page] */
Program(FETCH(temp8_, pc_), {MicroOp::Xor, &temp8_}), /* 0xee XOR n */
XX, /* 0xef RST 28h */
XX, /* 0xf0 RET p */
Program(POP(temp16_), {MicroOp::DisassembleAF}), /* 0xf1 POP AF */
JP(TestP), /* 0xf2 JP P */
XX, /* 0xf3 DI */
CALL(TestP), /* 0xf4 CALL P */
Program(WAIT(1), {MicroOp::AssembleAF}, PUSH(temp16_)), /* 0xf5 PUSH AF */
Program(FETCH(temp8_, pc_), {MicroOp::Or, &temp8_}), /* 0xf6 OR n */
XX, /* 0xf7 RST 30h */
XX, /* 0xf8 RET M */
Program(WAIT(2), {MicroOp::Move16, &hl_.full, &sp_.full}), /* 0xf9 LD SP, HL */
JP(TestM), /* 0xfa JP M */
XX, /* 0xfb EI */
CALL(TestM), /* 0xfc CALL M */
Program({MicroOp::SetInstructionPage, fd_page_}), /* 0xfd [FD page] */
Program(FETCH(temp8_, pc_), {MicroOp::CP8, &temp8_}), /* 0xfe CP n */
XX, /* 0xff RST 38h */
/* 0xc0 RET NZ */ RET(TestNZ), /* 0xc1 POP BC */ Program(POP(bc_)),
/* 0xc2 JP NZ */ JP(TestNZ), /* 0xc3 JP nn */ Program(FETCH16L(temp16_, pc_), {MicroOp::Move16, &temp16_.full, &pc_.full}),
/* 0xc4 CALL NZ */ CALL(TestNZ), /* 0xc5 PUSH BC */ Program(WAIT(1), PUSH(bc_)),
/* 0xc6 ADD A, n */ Program(FETCH(temp8_, pc_), {MicroOp::ADD8, &temp8_}),
/* 0xc7 RST 00h */ XX,
/* 0xc8 RET Z */ RET(TestZ), /* 0xc9 RET */ Program(POP(pc_)),
/* 0xca JP Z */ JP(TestZ), /* 0xcb [CB page] */XX,
/* 0xcc CALL Z */ CALL(TestZ), /* 0xcd CALL */ Program(FETCH16(temp16_, pc_), WAIT(1), PUSH(pc_), {MicroOp::Move16, &temp16_.full, &pc_.full}),
/* 0xce ADC A, n */ Program(FETCH(temp8_, pc_), {MicroOp::ADC8, &temp8_}),
/* 0xcf RST 08h */ XX,
/* 0xd0 RET NC */ RET(TestNC), /* 0xd1 POP DE */ Program(POP(de_)),
/* 0xd2 JP NC */ JP(TestNC), /* 0xd3 OUT (n), A */XX,
/* 0xd4 CALL NC */ CALL(TestNC), /* 0xd5 PUSH DE */ Program(WAIT(1), PUSH(de_)),
/* 0xd6 SUB n */ Program(FETCH(temp8_, pc_), {MicroOp::SUB8, &temp8_}),
/* 0xd7 RST 10h */ XX,
/* 0xd8 RET C */ RET(TestC), /* 0xd9 EXX */ XX,
/* 0xda JP C */ JP(TestC), /* 0xdb IN A, (n) */XX,
/* 0xdc CALL C */ CALL(TestC), /* 0xdd [DD page] */XX,
/* 0xde SBC A, n */ Program(FETCH(temp8_, pc_), {MicroOp::SBC8, &temp8_}),
/* 0xdf RST 18h */ XX,
/* 0xe0 RET PO */ RET(TestPO), /* 0xe1 POP HL */ Program(POP(hl_)),
/* 0xe2 JP PO */ JP(TestPO), /* 0xe3 EX (SP), HL */XX,
/* 0xe4 CALL PO */ CALL(TestPO), /* 0xe5 PUSH HL */ Program(WAIT(1), PUSH(hl_)),
/* 0xe6 AND n */ Program(FETCH(temp8_, pc_), {MicroOp::And, &temp8_}),
/* 0xe7 RST 20h */ XX,
/* 0xe8 RET PE */ RET(TestPE), /* 0xe9 JP (HL) */ XX,
/* 0xea JP PE */ JP(TestPE), /* 0xeb EX DE, HL */Program({MicroOp::ExDEHL}),
/* 0xec CALL PE */ CALL(TestPE), /* 0xed [ED page] */Program({MicroOp::SetInstructionPage, ed_page_}),
/* 0xee XOR n */ Program(FETCH(temp8_, pc_), {MicroOp::Xor, &temp8_}),
/* 0xef RST 28h */ XX,
/* 0xf0 RET p */ RET(TestP), /* 0xf1 POP AF */ Program(POP(temp16_), {MicroOp::DisassembleAF}),
/* 0xf2 JP P */ JP(TestP), /* 0xf3 DI */ XX,
/* 0xf4 CALL P */ CALL(TestP), /* 0xf5 PUSH AF */ Program(WAIT(1), {MicroOp::AssembleAF}, PUSH(temp16_)),
/* 0xf6 OR n */ Program(FETCH(temp8_, pc_), {MicroOp::Or, &temp8_}),
/* 0xf7 RST 30h */ XX,
/* 0xf8 RET M */ RET(TestM), /* 0xf9 LD SP, HL */Program(WAIT(2), {MicroOp::Move16, &hl_.full, &sp_.full}),
/* 0xfa JP M */ JP(TestM), /* 0xfb EI */ XX,
/* 0xfc CALL M */ CALL(TestM), /* 0xfd [FD page] */Program({MicroOp::SetInstructionPage, fd_page_}),
/* 0xfe CP n */ Program(FETCH(temp8_, pc_), {MicroOp::CP8, &temp8_}),
/* 0xff RST 38h */ XX,
};
assemble_page(target, base_program_table);
}