- `INSN_LD_reg_imm8: begin
- case (cycle)
- 0: begin
- `EXEC_INC_PC;
- `EXEC_NEXTADDR_PCINC;
- rd <= 1;
- end
- 1: begin
- `EXEC_INC_PC;
- if (opcode[5:3] == `INSN_reg_dHL) begin
- address <= {registers[`REG_H], registers[`REG_L]};
- wdata <= rdata;
- rd <= 0;
- wr <= 1;
- end else begin
- `EXEC_NEWCYCLE;
- end
- end
- 2: begin
- `EXEC_NEWCYCLE;
- end
- endcase
- end
- `INSN_HALT: begin
- `EXEC_NEWCYCLE;
- /* XXX Interrupts needed for HALT. */
- end
- `INSN_LD_HL_reg: begin
- case (cycle)
- 0: begin
- case (opcode[2:0])
- `INSN_reg_A: wdata <= registers[`REG_A];
- `INSN_reg_B: wdata <= registers[`REG_B];
- `INSN_reg_C: wdata <= registers[`REG_C];
- `INSN_reg_D: wdata <= registers[`REG_D];
- `INSN_reg_E: wdata <= registers[`REG_E];
- `INSN_reg_H: wdata <= registers[`REG_H];
- `INSN_reg_L: wdata <= registers[`REG_L];
- endcase
- address <= {registers[`REG_H], registers[`REG_L]};
- wr <= 1; rd <= 0;
- end
- 1: begin
- `EXEC_INC_PC;
- `EXEC_NEWCYCLE;
- end
- endcase
- end
- `INSN_LD_reg_HL: begin
- case(cycle)
- 0: begin
- address <= {registers[`REG_H], registers[`REG_L]};
- rd <= 1;
- end
- 1: begin
- tmp <= rdata;
- `EXEC_INC_PC;
- `EXEC_NEWCYCLE;
- end
- endcase
- end
- `INSN_LD_reg_reg: begin
- `EXEC_INC_PC;
- `EXEC_NEWCYCLE;
- case (opcode[2:0])
- `INSN_reg_A: tmp <= registers[`REG_A];
- `INSN_reg_B: tmp <= registers[`REG_B];
- `INSN_reg_C: tmp <= registers[`REG_C];
- `INSN_reg_D: tmp <= registers[`REG_D];
- `INSN_reg_E: tmp <= registers[`REG_E];
- `INSN_reg_H: tmp <= registers[`REG_H];
- `INSN_reg_L: tmp <= registers[`REG_L];
- endcase
- end
- `INSN_LD_reg_imm16: begin
- `EXEC_INC_PC;
- case (cycle)
- 0: begin
- `EXEC_NEXTADDR_PCINC;
- rd <= 1;
- end
- 1: begin
- `EXEC_NEXTADDR_PCINC;
- rd <= 1;
- end
- 2: begin `EXEC_NEWCYCLE; end
- endcase
- end
- `INSN_LD_SP_HL: begin
- case (cycle)
- 0: begin
- tmp <= registers[`REG_H];
- end
- 1: begin
- `EXEC_NEWCYCLE;
- `EXEC_INC_PC;
- tmp <= registers[`REG_L];
- end
- endcase
- end
- `INSN_PUSH_reg: begin /* PUSH is 16 cycles! */
- case (cycle)
- 0: begin
- wr <= 1;
- address <= {registers[`REG_SPH],registers[`REG_SPL]}-1;
- case (opcode[5:4])
- `INSN_stack_AF: wdata <= registers[`REG_A];
- `INSN_stack_BC: wdata <= registers[`REG_B];
- `INSN_stack_DE: wdata <= registers[`REG_D];
- `INSN_stack_HL: wdata <= registers[`REG_H];
- endcase
- end
- 1: begin
- wr <= 1;
- address <= {registers[`REG_SPH],registers[`REG_SPL]}-1;
- case (opcode[5:4])
- `INSN_stack_AF: wdata <= registers[`REG_F];
- `INSN_stack_BC: wdata <= registers[`REG_C];
- `INSN_stack_DE: wdata <= registers[`REG_E];
- `INSN_stack_HL: wdata <= registers[`REG_L];
- endcase
- end
- 2: begin /* TWIDDLE OUR FUCKING THUMBS! */ end
- 3: begin
- `EXEC_NEWCYCLE;
- `EXEC_INC_PC;
- end
- endcase
- end
- `INSN_POP_reg: begin /* POP is 12 cycles! */
- case (cycle)
- 0: begin
- rd <= 1;
- address <= {registers[`REG_SPH],registers[`REG_SPL]};
- end
- 1: begin
- rd <= 1;
- address <= {registers[`REG_SPH],registers[`REG_SPL]};
- end
- 2: begin
- `EXEC_NEWCYCLE;
- `EXEC_INC_PC;
- end
- endcase
- end