diff --git a/op_load16.go b/op_load16.go index e8bc97c..78dbaab 100644 --- a/op_load16.go +++ b/op_load16.go @@ -76,7 +76,7 @@ func oopPOPIY(cpu *CPU) { ////////////////////////////////////////////////////////////////////////////// // eXpanded OPration codes -func xopPUSHreg(cpu *CPU, reg Register) { +func copPUSHreg(cpu *CPU, reg Register) { // Code before optimization //cpu.SP -= 2 //cpu.Memory.Set(cpu.SP, reg.Lo) @@ -87,7 +87,23 @@ func xopPUSHreg(cpu *CPU, reg Register) { cpu.Memory.Set(cpu.SP, reg.Lo) } -func xopPOPreg(cpu *CPU, reg *Register) { +func xopPUSHbc(cpu *CPU) { + copPUSHreg(cpu, cpu.BC) +} + +func xopPUSHde(cpu *CPU) { + copPUSHreg(cpu, cpu.DE) +} + +func xopPUSHhl(cpu *CPU) { + copPUSHreg(cpu, cpu.HL) +} + +func xopPUSHaf(cpu *CPU) { + copPUSHreg(cpu, cpu.AF) +} + +func copPOPreg(cpu *CPU, reg *Register) { // Code before optimization //reg.Lo = cpu.Memory.Get(cpu.SP) //reg.Hi = cpu.Memory.Get(cpu.SP + 1) @@ -98,6 +114,22 @@ func xopPOPreg(cpu *CPU, reg *Register) { cpu.SP++ } +func xopPOPbc(cpu *CPU) { + copPOPreg(cpu, &cpu.BC) +} + +func xopPOPde(cpu *CPU) { + copPOPreg(cpu, &cpu.DE) +} + +func xopPOPhl(cpu *CPU) { + copPOPreg(cpu, &cpu.HL) +} + +func xopPOPaf(cpu *CPU) { + copPOPreg(cpu, &cpu.AF) +} + func xopLDbcnn(cpu *CPU) { cpu.BC.Lo, cpu.BC.Hi = cpu.fetch2() } diff --git a/operation.go b/operation.go index 8a047fb..c928831 100644 --- a/operation.go +++ b/operation.go @@ -473,13 +473,13 @@ func (cpu *CPU) executeOne() { xopRETfS(cpu) case 0xc1: - xopPOPreg(cpu, &cpu.BC) + xopPOPbc(cpu) case 0xd1: - xopPOPreg(cpu, &cpu.DE) + xopPOPde(cpu) case 0xe1: - xopPOPreg(cpu, &cpu.HL) + xopPOPhl(cpu) case 0xf1: - xopPOPreg(cpu, &cpu.AF) + xopPOPaf(cpu) case 0xc2: xopJPnZnn(cpu) @@ -519,13 +519,13 @@ func (cpu *CPU) executeOne() { xopCALLfSnn(cpu) case 0xc5: - xopPUSHreg(cpu, cpu.BC) + xopPUSHbc(cpu) case 0xd5: - xopPUSHreg(cpu, cpu.DE) + xopPUSHde(cpu) case 0xe5: - xopPUSHreg(cpu, cpu.HL) + xopPUSHhl(cpu) case 0xf5: - xopPUSHreg(cpu, cpu.AF) + xopPUSHaf(cpu) case 0xc6: oopADDAn(cpu)