1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 23:52:26 +00:00

Eliminates implicit type conversion.

This commit is contained in:
Thomas Harte 2019-04-14 21:02:28 -04:00
parent 325af677d3
commit 75d8824e6b

View File

@ -380,47 +380,49 @@ template <class T, bool dtack_is_implicit> void Processor<T, dtack_is_implicit>:
mask = next_word_; \ mask = next_word_; \
int offset = 0; int offset = 0;
#define write_address_sequence_long(address_step, offset_step, l, h) \ #define inc_action(x, v) x += v
while(mask) { \ #define dec_action(x, v) x -= v
if(mask&1) { \
address_storage[0] = start_address; \ #define write_address_sequence_long(action, l) \
address_storage[1] = start_address + address_step; \ while(mask) { \
\ if(mask&1) { \
step[0].microcycle.address = step[1].microcycle.address = address_storage; \ address_storage[0] = start_address; \
step[2].microcycle.address = step[3].microcycle.address = address_storage + 1; \ action(start_address, 2); \
\ address_storage[1] = start_address; \
const auto target = (offset > 7) ? &address_[offset&7] : &data_[offset]; \ action(start_address, 2); \
step[h].microcycle.value = step[h+1].microcycle.value = &target->halves.high; \ \
step[l].microcycle.value = step[l+1].microcycle.value = &target->halves.low; \ step[0].microcycle.address = step[1].microcycle.address = address_storage; \
\ step[2].microcycle.address = step[3].microcycle.address = address_storage + 1; \
start_address += address_step*2; \ \
address_storage += 2; \ const auto target = (offset > 7) ? &address_[offset&7] : &data_[offset]; \
step += 4; \ step[(l^2)].microcycle.value = step[(l^2)+1].microcycle.value = &target->halves.high; \
} \ step[l].microcycle.value = step[l+1].microcycle.value = &target->halves.low; \
mask >>= 1; \ \
offset += offset_step; \ address_storage += 2; \
step += 4; \
} \
mask >>= 1; \
action(offset, 1); \
} }
#define write_address_sequence_word(address_step, offset_step) \ #define write_address_sequence_word(action) \
while(mask) { \ while(mask) { \
if(mask&1) { \ if(mask&1) { \
address_storage[0] = start_address; \ address_storage[0] = start_address; \
action(start_address, 2); \
\ \
step[0].microcycle.address = step[1].microcycle.address = address_storage; \ step[0].microcycle.address = step[1].microcycle.address = address_storage; \
\ \
const auto target = (offset > 7) ? &address_[offset&7] : &data_[offset]; \ const auto target = (offset > 7) ? &address_[offset&7] : &data_[offset]; \
step[0].microcycle.value = step[1].microcycle.value = &target->halves.low; \ step[0].microcycle.value = step[1].microcycle.value = &target->halves.low; \
\ \
start_address += address_step; \
++ address_storage; \ ++ address_storage; \
step += 2; \ step += 2; \
} \ } \
mask >>= 1; \ mask >>= 1; \
offset += offset_step; \ action(offset, 1); \
} }
case Operation::MOVEMtoRl: { case Operation::MOVEMtoRl: {
setup_movem(2, movem_reads_steps_); setup_movem(2, movem_reads_steps_);
@ -434,7 +436,7 @@ template <class T, bool dtack_is_implicit> void Processor<T, dtack_is_implicit>:
// //
// The latter part is dealt with by MicroOp::Action::MOVEMtoRComplete, which also // The latter part is dealt with by MicroOp::Action::MOVEMtoRComplete, which also
// does any necessary sign extension. // does any necessary sign extension.
write_address_sequence_long(2, 1, 0, 2); write_address_sequence_long(inc_action, 0);
// MOVEM to R always reads one word too many. // MOVEM to R always reads one word too many.
address_storage[0] = start_address; address_storage[0] = start_address;
@ -445,7 +447,7 @@ template <class T, bool dtack_is_implicit> void Processor<T, dtack_is_implicit>:
case Operation::MOVEMtoRw: { case Operation::MOVEMtoRw: {
setup_movem(1, movem_reads_steps_); setup_movem(1, movem_reads_steps_);
write_address_sequence_word(2, 1); write_address_sequence_word(inc_action);
// MOVEM to R always reads one word too many. // MOVEM to R always reads one word too many.
address_storage[0] = start_address; address_storage[0] = start_address;
@ -470,10 +472,10 @@ template <class T, bool dtack_is_implicit> void Processor<T, dtack_is_implicit>:
if(mode == 4) { if(mode == 4) {
offset = 15; offset = 15;
start_address -= 2; start_address -= 2;
write_address_sequence_long(-2, -1, 2, 0); write_address_sequence_long(dec_action, 2);
movem_final_address_ = start_address; movem_final_address_ = start_address;
} else { } else {
write_address_sequence_long(2, 1, 0, 2); write_address_sequence_long(inc_action, 0);
} }
} break; } break;
@ -483,15 +485,17 @@ template <class T, bool dtack_is_implicit> void Processor<T, dtack_is_implicit>:
if(mode == 4) { if(mode == 4) {
offset = 15; offset = 15;
start_address -= 2; start_address -= 2;
write_address_sequence_word(-2, -1); write_address_sequence_word(dec_action);
} else { } else {
write_address_sequence_word(2, 1); write_address_sequence_word(inc_action);
} }
} break; } break;
#undef setup_movem #undef setup_movem
#undef write_address_sequence_long #undef write_address_sequence_long
#undef write_address_sequence_word #undef write_address_sequence_word
#undef inc_action
#undef dec_action
/* /*
NEGs: negatives the destination, setting the zero, NEGs: negatives the destination, setting the zero,