Skip to content

Commit

Permalink
[#6] Store CF in the eighth bit of 'w' for DAA.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Jun 20, 2021
1 parent 0c45cef commit 629bf86
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -2444,8 +2444,8 @@ class i8080_executor : public internals::executor_base<B> {
return static_cast<fast_u8>((f & ~cf_mask) | w);
case flag_op::daa: {
fast_u8 t = b;
fast_u8 hf_cf = static_cast<fast_u8>(w);
return sf(t) | zf(t) | pf(t) | hf_cf; }
fast_u8 hf = static_cast<fast_u8>(w & hf_mask);
return sf(t) | zf(t) | pf(t) | hf | cfa(w); }
}
unreachable("Unknown flag set!");
}
Expand Down Expand Up @@ -2530,12 +2530,12 @@ class i8080_executor : public internals::executor_base<B> {
r = t;

fast_u16 t2 = r + 0x60;
fast_u8 cfv = ((t2 >> 8) | f) & cf_mask;
if(cfv)
fast_u16 w = ((t2 >> 8) | f) << 8;
if(w & 0x100)
r = mask8(t2);

self().on_set_a(r);
self().on_flags_update(f, flag_op::daa, r, (hfv & hf_mask) | cfv); }
self().on_flags_update(f, flag_op::daa, r, w | hfv); }
void on_dec_r(reg r) {
fast_u8 n = self().on_get_reg(r);
fast_u8 f = self().on_get_f();
Expand Down

0 comments on commit 629bf86

Please sign in to comment.