From: Joshua Wise Date: Fri, 9 May 2008 09:34:07 +0000 (-0400) Subject: Cut 1 at ADD HL,... X-Git-Url: http://git.joshuawise.com/fpgaboy.git/commitdiff_plain/00a4c19f8e97b088b9385af67f530c2ddecb92ce?ds=inline Cut 1 at ADD HL,... --- diff --git a/GBZ80Core.v b/GBZ80Core.v index 29aab52..053df4a 100644 --- a/GBZ80Core.v +++ b/GBZ80Core.v @@ -79,6 +79,7 @@ `define INSN_BIT 9'b101xxxxxx `define INSN_RES 9'b110xxxxxx `define INSN_SET 9'b111xxxxxx +`define INSN_ADD_HL 9'b000xx1001 `define INSN_cc_NZ 2'b00 `define INSN_cc_Z 2'b01 diff --git a/Makefile b/Makefile index 5e50da8..40ea542 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ VLOGS_ALL = $(VLOGS) insn_call-callcc.v insn_incdec16.v insn_jr-jrcc.v \ CPUDCM.v insn_alu_a.v insn_halt.v insn_jp-jpcc.v insn_ld_hl_reg.v \ insn_ld_reg_imm8.v insn_ldx_ahl.v insn_push_reg.v insn_vop_intr.v \ insn_ldm8_a.v insn_ldm16_a.v insn_ldbcde_a.v insn_alu_ext.v \ - insn_bit.v insn_two_byte.v insn_incdec_reg8.v + insn_bit.v insn_two_byte.v insn_incdec_reg8.v insn_add_hl.v all: CoreTop.svf diff --git a/allinsns.v b/allinsns.v index 6c1c487..dfdf04f 100644 --- a/allinsns.v +++ b/allinsns.v @@ -29,3 +29,4 @@ `include "insn_two_byte.v" `include "insn_bit.v" `include "insn_alu_ext.v" +`include "insn_add_hl.v" diff --git a/insn_add_hl.v b/insn_add_hl.v new file mode 100644 index 0000000..8ff25f4 --- /dev/null +++ b/insn_add_hl.v @@ -0,0 +1,33 @@ +`ifdef EXECUTE + `INSN_ADD_HL: begin + case (cycle) + 0: case (opcode[5:4]) + `INSN_reg16_BC: {tmp,tmp2} <= `_BC; + `INSN_reg16_DE: {tmp,tmp2} <= `_DE; + `INSN_reg16_HL: {tmp,tmp2} <= `_HL; + `INSN_reg16_SP: {tmp,tmp2} <= `_SP; + endcase + 1: begin + `EXEC_INC_PC + `EXEC_NEWCYCLE + end + endcase + end +`endif + +`ifdef WRITEBACK + `INSN_ADD_HL: begin + case (cycle) + 0: {tmp,tmp2} <= `_HL + {tmp,tmp2}; + 1: begin + `_F <= { /* Z */ `_F[7], + /* N */ 1'b0, + /* H */ (({`_HL} + {tmp,tmp2}) & 16'h1000) ? 1'b1 : 1'b0, + /* C */ (({1'b0,`_HL} + {1'b0,tmp,tmp2}) >> 16 == 1) ? 1'b1 : 1'b0, + `_F[3:0] + }; + `_HL <= {tmp, tmp2}; + end + endcase + end +`endif diff --git a/opcodes b/opcodes index 09f68fb..451a6b6 100644 --- a/opcodes +++ b/opcodes @@ -8,11 +8,7 @@ imm16 = 16-bit immediate value bits insn notes 0000 1000 LD 16m16,SP loads SP -0000 1001 ADD HL, BC 0001 0000 STOP -0001 1001 ADD HL, DE -0010 1001 ADD HL, HL -0011 1001 ADD HL, SP 0111 0110 HALT Danger! Helvetica! 1100 1011 - - - see two-byte opcodes below 1110 1000 ADD SP, imm8