Skip to content

Commit

Permalink
[#6] Get rid of extra F register readings in i8080 ALU instructions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Jun 20, 2021
1 parent 5b32eb8 commit b977ab8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 15 deletions.
12 changes: 0 additions & 12 deletions tests/tests_i8080
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ ce16 aci 0x16
4 set_pc_on_fetch 0000 -> 0001
4 get_a 00
4 get_a 00
4 get_f 00
4 set_a 00 -> 00
4 set_f 00 -> 44
4 done
Expand Down Expand Up @@ -68,7 +67,6 @@ c616 adi 0x16
6 mreq_wait 0001
7 set_pc_on_imm8_read 0001 -> 0002
7 get_a 00
7 get_f 00
7 set_a 00 -> 16
7 set_f 00 -> 00
7 done
Expand All @@ -82,7 +80,6 @@ a7 ana a
4 set_pc_on_fetch 0000 -> 0001
4 get_a 00
4 get_a 00
4 get_f 00
4 set_a 00 -> 00
4 set_f 00 -> 44
4 done
Expand All @@ -101,7 +98,6 @@ e616 ani 0x16
6 mreq_wait 0001
7 set_pc_on_imm8_read 0001 -> 0002
7 get_a 00
7 get_f 00
7 set_a 00 -> 00
7 set_f 00 -> 44
7 done
Expand Down Expand Up @@ -208,7 +204,6 @@ bc cmp h
4 set_pc_on_fetch 0000 -> 0001
4 get_h 00
4 get_a 00
4 get_f 00
4 set_f 00 -> 54
4 done

Expand All @@ -226,7 +221,6 @@ fe16 cpi 0x16
6 mreq_wait 0001
7 set_pc_on_imm8_read 0001 -> 0002
7 get_a 00
7 get_f 00
7 set_f 00 -> 81
7 done

Expand Down Expand Up @@ -538,7 +532,6 @@ b3 ora e
4 set_pc_on_fetch 0000 -> 0001
4 get_e 00
4 get_a 00
4 get_f 00
4 set_a 00 -> 00
4 set_f 00 -> 44
4 done
Expand All @@ -557,7 +550,6 @@ f616 ori 0x16
6 mreq_wait 0001
7 set_pc_on_imm8_read 0001 -> 0002
7 get_a 00
7 get_f 00
7 set_a 00 -> 16
7 set_f 00 -> 00
7 done
Expand Down Expand Up @@ -700,7 +692,6 @@ f9 sphl
4 set_pc_on_fetch 0000 -> 0001
4 get_c 00
4 get_a 00
4 get_f 00
4 set_a 00 -> 00
4 set_f 00 -> 54
4 done
Expand All @@ -719,7 +710,6 @@ d616 sui 0x16
6 mreq_wait 0001
7 set_pc_on_imm8_read 0001 -> 0002
7 get_a 00
7 get_f 00
7 set_a 00 -> ea
7 set_f 00 -> 81
7 done
Expand Down Expand Up @@ -988,7 +978,6 @@ af xra a
4 set_pc_on_fetch 0000 -> 0001
4 get_a 00
4 get_a 00
4 get_f 00
4 set_a 00 -> 00
4 set_f 00 -> 44
4 done
Expand All @@ -1007,7 +996,6 @@ ee16 xri 0x16
6 mreq_wait 0001
7 set_pc_on_imm8_read 0001 -> 0002
7 get_a 00
7 get_f 00
7 set_a 00 -> 16
7 set_f 00 -> 00
7 done
Expand Down
6 changes: 3 additions & 3 deletions z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -2471,13 +2471,13 @@ class i8080_executor : public internals::executor_base<B> {
public:
void do_alu(alu k, fast_u8 n) {
fast_u8 a = self().on_get_a();
fast_u8 f = self().on_get_f();
flag_op fop;
fast_u16 t, w;
fast_u8 b;
if(((static_cast<unsigned>(k) + 1) & 0x7) < 5) {
// ADD, ADC, SUB, SBC, CP
fast_u8 cfv = (k == alu::adc || k == alu::sbc) ? cf(f) : 0;
fast_u8 cfv = (k == alu::adc || k == alu::sbc) ?
cf(self().on_get_f()) : 0;
if(k <= alu::adc) {
t = a + n + cfv;
fop = flag_op::adc;
Expand Down Expand Up @@ -2507,7 +2507,7 @@ class i8080_executor : public internals::executor_base<B> {
}
if(k != alu::cp)
self().on_set_a(mask8(t));
self().on_flags_update(f, fop, b, w);
self().on_flags_update(/* f= */ 0, fop, b, w);
}

void on_add_irp_rp(regp rp) {
Expand Down

0 comments on commit b977ab8

Please sign in to comment.