mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-28 06:29:37 +00:00
Transcribe op_X macros.
This commit is contained in:
parent
4838728521
commit
f136151064
@ -547,6 +547,11 @@ template <Operation operation> void Executor::perform(uint8_t *operand [[maybe_u
|
|||||||
const auto set_nz = [&](uint8_t result) {
|
const auto set_nz = [&](uint8_t result) {
|
||||||
negative_result_ = zero_result_ = result;
|
negative_result_ = zero_result_ = result;
|
||||||
};
|
};
|
||||||
|
const auto op_cmp = [&](uint8_t x) {
|
||||||
|
const uint16_t temp16 = x - *operand;
|
||||||
|
set_nz(uint8_t(temp16));
|
||||||
|
carry_flag_ = (~temp16 >> 8)&1;
|
||||||
|
};
|
||||||
|
|
||||||
switch(operation) {
|
switch(operation) {
|
||||||
case Operation::LDA:
|
case Operation::LDA:
|
||||||
@ -688,22 +693,27 @@ template <Operation operation> void Executor::perform(uint8_t *operand [[maybe_u
|
|||||||
op(a_); \
|
op(a_); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define op_ora(x) set_nz(x |= *operand)
|
case Operation::ORA: {
|
||||||
#define op_and(x) set_nz(x &= *operand)
|
const auto op_ora = [&](uint8_t x) {
|
||||||
#define op_eor(x) set_nz(x ^= *operand)
|
set_nz(x |= *operand);
|
||||||
case Operation::ORA: index(op_ora); break;
|
};
|
||||||
case Operation::AND: index(op_and); break;
|
index(op_ora);
|
||||||
case Operation::EOR: index(op_eor); break;
|
} break;
|
||||||
#undef op_eor
|
case Operation::AND: {
|
||||||
#undef op_and
|
const auto op_and = [&](uint8_t x) {
|
||||||
#undef op_ora
|
set_nz(x &= *operand);
|
||||||
|
};
|
||||||
|
index(op_and);
|
||||||
|
} break;
|
||||||
|
case Operation::EOR: {
|
||||||
|
const auto op_eor = [&](uint8_t x) {
|
||||||
|
set_nz(x ^= *operand);
|
||||||
|
};
|
||||||
|
index(op_eor);
|
||||||
|
} break;
|
||||||
|
|
||||||
#undef index
|
#undef index
|
||||||
|
|
||||||
#define op_cmp(x) { \
|
|
||||||
const uint16_t temp16 = x - *operand; \
|
|
||||||
set_nz(uint8_t(temp16)); \
|
|
||||||
carry_flag_ = (~temp16 >> 8)&1; \
|
|
||||||
}
|
|
||||||
case Operation::CMP:
|
case Operation::CMP:
|
||||||
if(index_mode_) {
|
if(index_mode_) {
|
||||||
op_cmp(read(x_));
|
op_cmp(read(x_));
|
||||||
@ -713,7 +723,6 @@ template <Operation operation> void Executor::perform(uint8_t *operand [[maybe_u
|
|||||||
break;
|
break;
|
||||||
case Operation::CPX: op_cmp(x_); break;
|
case Operation::CPX: op_cmp(x_); break;
|
||||||
case Operation::CPY: op_cmp(y_); break;
|
case Operation::CPY: op_cmp(y_); break;
|
||||||
#undef op_cmp
|
|
||||||
|
|
||||||
case Operation::SBC:
|
case Operation::SBC:
|
||||||
case Operation::ADC: {
|
case Operation::ADC: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user