]> Joshua Wise's Git repositories - fpgaboy.git/commitdiff
Fix some flag bugs in INC and DEC
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 22 May 2008 03:32:51 +0000 (23:32 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Thu, 22 May 2008 03:32:51 +0000 (23:32 -0400)
broken-tests
core/insn_incdec_hl.v
core/insn_incdec_reg8.v

index a164b5d31f0bf3615098f484590e7eb33314421a..e388d35cf125bf8d74b7ff44b39f021ebdfbcd17 100644 (file)
@@ -11,22 +11,11 @@ TEST 04: LD r,r
 TEST 05: Misc insns
 
 TEST 06: (HL/BC/DE) insns
-35 (DEC (HL))
-34 (INC (HL))
 CB 1E (RR (HL))
 
 TEST 07: Immediate insns
 
 TEST 08: Register insns
-37 (SCF)
-3F (CCF)
-05 (DEC B)
-0D (DEC C)
-15 (DEC D)
-1D (DEC E)
-25 (DEC H)
-2D (DEC L)
-3D (DEC A)
 07 (RLCA)
 17 (RLA)
 0F (RRCA)
index 1406fd8b9890e77a3ff7065663001c440ebd9954..656353a0fd754f369676b5c12333b5516140639d 100644 (file)
@@ -4,7 +4,10 @@
        `INSN_INCDEC_HL: begin
                case (cycle)
                0:      `EXEC_READ(`_HL)
-               1:      `EXEC_WRITE(`_HL, rdata + (opcode[0] ? 8'hFF : 8'h01))
+               1:      begin
+                               `EXEC_WRITE(`_HL, rdata + (opcode[0] ? 8'hFF : 8'h01))
+                               tmp <= rdata + (opcode[0] ? 8'hFF : 8'h01);
+                       end
                2:      begin
                                `EXEC_INC_PC
                                `EXEC_NEWCYCLE
 
 `ifdef WRITEBACK
        `INSN_INCDEC_HL: begin
-               /* meh meh */
+               if (cycle == 1)
+                       `_F <= {
+                               (tmp == 8'h00) ? 1'b1 : 1'b0,   /* Z */
+                               opcode[0],       /* N */
+                               (tmp[3:0] == (opcode[0] ? 4'hF : 4'h0)) ? 1'b1 : 1'b0,
+                               `_F[4:0]
+                       };
        end
 `endif
index e89ceba54d63903c91776137d37ba5df4b78e729..b7ed993068cd38cee0a5e87b09c4f99366a9eb30 100644 (file)
@@ -5,13 +5,13 @@
                `EXEC_INC_PC
                `EXEC_NEWCYCLE
                case (opcode[5:3])
-               `INSN_reg_A:    tmp <= `_A;
-               `INSN_reg_B:    tmp <= `_B;
-               `INSN_reg_C:    tmp <= `_C;
-               `INSN_reg_D:    tmp <= `_D;
-               `INSN_reg_E:    tmp <= `_E;
-               `INSN_reg_H:    tmp <= `_H;
-               `INSN_reg_L:    tmp <= `_L;
+               `INSN_reg_A:    tmp <= `_A + (opcode[0] ? 8'hFF : 8'h01);
+               `INSN_reg_B:    tmp <= `_B + (opcode[0] ? 8'hFF : 8'h01);
+               `INSN_reg_C:    tmp <= `_C + (opcode[0] ? 8'hFF : 8'h01);
+               `INSN_reg_D:    tmp <= `_D + (opcode[0] ? 8'hFF : 8'h01);
+               `INSN_reg_E:    tmp <= `_E + (opcode[0] ? 8'hFF : 8'h01);
+               `INSN_reg_H:    tmp <= `_H + (opcode[0] ? 8'hFF : 8'h01);
+               `INSN_reg_L:    tmp <= `_L + (opcode[0] ? 8'hFF : 8'h01);
                endcase
        end
 `endif
 `ifdef WRITEBACK
        `INSN_INCDEC_reg8: begin
                case (opcode[5:3])
-               `INSN_reg_A:    `_A <= tmp + (opcode[0] ? 8'hFF : 8'h01);
-               `INSN_reg_B:    `_B <= tmp + (opcode[0] ? 8'hFF : 8'h01);
-               `INSN_reg_C:    `_C <= tmp + (opcode[0] ? 8'hFF : 8'h01);
-               `INSN_reg_D:    `_D <= tmp + (opcode[0] ? 8'hFF : 8'h01);
-               `INSN_reg_E:    `_E <= tmp + (opcode[0] ? 8'hFF : 8'h01);
-               `INSN_reg_H:    `_H <= tmp + (opcode[0] ? 8'hFF : 8'h01);
-               `INSN_reg_L:    `_L <= tmp + (opcode[0] ? 8'hFF : 8'h01);
+               `INSN_reg_A:    `_A <= tmp;
+               `INSN_reg_B:    `_B <= tmp;
+               `INSN_reg_C:    `_C <= tmp;
+               `INSN_reg_D:    `_D <= tmp;
+               `INSN_reg_E:    `_E <= tmp;
+               `INSN_reg_H:    `_H <= tmp;
+               `INSN_reg_L:    `_L <= tmp;
                endcase
                `_F <= {
-                               ((tmp + (opcode[0] ? 8'hFF : 8'h01)) == 8'h00) ? 1'b1 : 1'b0,
-                               1'b0,
-                               (({1'b0,tmp[3:0]} + (opcode[0] ? 5'h1F : 5'h01)) >> 4) ? 1'b1 : 1'b0,
-                               `_F[4:0]};
+                               (tmp == 8'h00) ? 1'b1 : 1'b0,   /* Z */
+                               opcode[0],       /* N */
+                               (tmp[3:0] == (opcode[0] ? 4'hF : 4'h0)) ? 1'b1 : 1'b0,
+                               `_F[4:0]
+                       };
        end
 `endif
This page took 0.035817 seconds and 4 git commands to generate.