Skip to content

Commit

Permalink
[#15] Combine on_ld_sp_irp().
Browse files Browse the repository at this point in the history
  • Loading branch information
kosarev committed Aug 27, 2021
1 parent 519fc11 commit c14e2f3
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions z80.h
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,12 @@ class internals::disasm_base : public B {
self().on_format("di"); }
void on_ei() {
self().on_format("ei"); }
void on_ld_sp_irp() {
if(!self().on_is_z80()) {
self().on_format("sphl");
} else {
iregp irp = self().on_get_iregp_kind();
self().on_format("ld sp, P", regp::hl, irp); } }
void on_ld_rp_nn(regp rp, fast_u16 nn) {
if(!self().on_is_z80()) {
self().on_format("lxi P, W", rp, nn);
Expand Down Expand Up @@ -1571,8 +1577,6 @@ class i8080_disasm : public internals::disasm_base<i8080_decoder<root<D>>> {
self().on_format("mvi R, N", r, n); }
void on_ld_r_r(reg rd, reg rs) {
self().on_format("mov R, R", rd, rs); }
void on_ld_sp_irp() {
self().on_format("sphl"); }
void on_ld_irp_at_nn(fast_u16 nn) {
self().on_format("lhld W", nn); }
void on_ld_at_nn_irp(fast_u16 nn) {
Expand Down Expand Up @@ -1853,9 +1857,6 @@ class z80_disasm
self().on_format("ld a, (P)", rp, iregp::hl); }
void on_ld_at_rp_a(regp rp) {
self().on_format("ld (P), a", rp, iregp::hl); }
void on_ld_sp_irp() {
iregp irp = self().on_get_iregp_kind();
self().on_format("ld sp, P", regp::hl, irp); }
void on_xim(fast_u8 op, fast_u8 mode) {
self().on_format("xim W, U", 0xed00 | op, mode); }
void on_xneg(fast_u8 op) {
Expand Down Expand Up @@ -2717,6 +2718,12 @@ class internals::executor_base : public B {
self().on_set_reg(access_r, irp, d, v);
if(irp != iregp::hl && r != reg::at_hl)
self().on_set_reg(r, irp, /* d= */ 0, v); }
void on_ld_sp_irp() {
if(!self().on_is_z80()) {
self().on_set_sp(self().on_get_hl());
} else {
iregp irp = self().on_get_iregp_kind();
self().on_set_sp(self().on_get_iregp(irp)); } }
void on_ld_rp_nn(regp rp, fast_u16 nn) {
// TODO: Unify on_set_regp()?
if(!self().on_is_z80()) {
Expand Down Expand Up @@ -3391,8 +3398,6 @@ class i8080_executor : public internals::executor_base<B> {
void on_ld_r_r(reg rd, reg rs) {
self().on_fetch_cycle_extra_1t();
self().on_set_reg(rd, self().on_get_reg(rs)); }
void on_ld_sp_irp() {
self().on_set_sp(self().on_get_hl()); }
void on_ld_irp_at_nn(fast_u16 nn) {
fast_u8 lo = self().on_read_cycle(nn);
nn = inc16(nn);
Expand Down Expand Up @@ -3965,9 +3970,6 @@ class z80_executor : public internals::executor_base<B> {
nn = inc16(nn);
self().on_set_wz(nn);
self().on_write_cycle(nn, get_high8(rpv)); }
void on_ld_sp_irp() {
iregp irp = self().on_get_iregp_kind();
self().on_set_sp(self().on_get_iregp(irp)); }

protected:
using base::self;
Expand Down

0 comments on commit c14e2f3

Please sign in to comment.