Skip to content

Commit

Permalink
SM83: Fix high nibble result of "ADD SP, e"
Browse files Browse the repository at this point in the history
  • Loading branch information
msinger committed Feb 21, 2021
1 parent d6279fb commit 289ec21
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/cpu/sm83_control.sv
Original file line number Diff line number Diff line change
Expand Up @@ -1924,7 +1924,11 @@ module sm83_control(
update_alu_flags(0|0|H|0);
end

m3 && t4: begin
m3 && t4:;

m4 && t1:;

m4 && t2: begin
/* Use half carry for high nibble calculation */
ctl_alu_sel_hc = 1;

Expand All @@ -1937,12 +1941,10 @@ module sm83_control(
/* Update ALU flags */
ctl_alu_fl_neg_clr = 1;
update_alu_flags(0|N|0|C);
end

m4 && t1:;

/* Write ALU result into high byte of SP */
m4 && t2: sp_from_alu(HIGH);
/* Write ALU result into high byte of SP */
sp_from_alu(HIGH);
end

/* Write ALU flags into register F */
m4 && t3: f_from_alu();
Expand Down

0 comments on commit 289ec21

Please sign in to comment.