]> Joshua Wise's Git repositories - fpgaboy.git/blobdiff - core/insn_add_hl.v
Fix bugs in SCF and CCF
[fpgaboy.git] / core / insn_add_hl.v
index 8ff25f46b00b11b49f1f19e547146359c1e1fb2d..6bd7e7a8dc17e8599cf6497eeb46b835cca827fd 100644 (file)
@@ -1,3 +1,5 @@
+`define INSN_ADD_HL            9'b000xx1001
+
 `ifdef EXECUTE
        `INSN_ADD_HL: begin
                case (cycle)
 `ifdef EXECUTE
        `INSN_ADD_HL: begin
                case (cycle)
 `ifdef WRITEBACK
        `INSN_ADD_HL: begin
                case (cycle)
 `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,
                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,
+                                         /* C */ (({1'b0,`_HL} + {1'b0,tmp,tmp2}) & 17'h10000) ? 1'b1 : 1'b0,
                                          `_F[3:0]
                                        };
                                          `_F[3:0]
                                        };
-                               `_HL <= {tmp, tmp2};
+                               `_HL <= `_HL + {tmp, tmp2};
                        end
                endcase
        end
                        end
                endcase
        end
This page took 0.027533 seconds and 4 git commands to generate.