From: Joshua Wise Date: Tue, 15 Apr 2008 05:09:02 +0000 (-0400) Subject: Fix ld [] and ld [] X-Git-Url: http://git.joshuawise.com/fpgaboy.git/commitdiff_plain/f6fa1d6e1393de5d18302b8674ed1616afdfcefb?ds=sidebyside Fix ld [] and ld [] --- diff --git a/Makefile b/Makefile index 9751d4e..3cabf3f 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ VLOGS = 7seg.v GBZ80Core.v insn_call-callcc.v insn_incdec16.v \ insn_ld_sp_hl.v insn_pop_reg.v insn_rst.v System.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 \ - Timer.v LCDC.v insn_ldm_a.v Framebuffer.v + Timer.v LCDC.v insn_ldm8_a.v insn_ldm16_a.v Framebuffer.v all: CoreTop_rom.svf CoreTop_diag.svf CoreTop.twr diff --git a/allinsns.v b/allinsns.v index 3097f3d..8d33aa2 100644 --- a/allinsns.v +++ b/allinsns.v @@ -23,4 +23,5 @@ `include "insn_di-ei.v" `include "insn_incdec_hl.v" `include "insn_incdec_reg8.v" -`include "insn_ldm_a.v" +`include "insn_ldm8_a.v" +`include "insn_ldm16_a.v" diff --git a/diag.asm b/diag.asm index 8016400..8e09874 100644 --- a/diag.asm +++ b/diag.asm @@ -55,9 +55,8 @@ vbl: PUSH HL xor a - ld c, $0F - ld [c], a - + ld [$FF0F], a + ld c, $42 ; SCY ld a, [c] inc a @@ -75,8 +74,7 @@ lcdc: PUSH BC xor a - ld c, $0F - ld [c], a + ld [$FF0F], a POP BC POP AF @@ -90,25 +88,23 @@ tmro: PUSH HL xor a - ld c, $0F - ld [c], a + ld [$FF0F], a ld c, $45 ; LYC ld a, [c] inc a ld [c], a - ld hl, $DF82 - ld a, [hld] + ld a, [$DF82] cp 0 jr z, .noprint ld a, $41 ; print A call putc .noprint: - inc [hl] - ld a, [hl] - ld c, $51 - ld [c], a + ld a, [$DF81] + inc a + ld [$DF81], a + ld [$FF51], a POP HL POP DE @@ -121,7 +117,7 @@ memtest: ld hl,memteststr call puts - ld hl, $C001 ; Write loop + ld hl, $C000 ; Write loop .wr: ld a,h xor l @@ -133,7 +129,7 @@ memtest: cp $80 jr nz, .wr - ld hl, $C001 ; Read loop + ld hl, $C000 ; Read loop .rd: ld a,h xor l @@ -154,7 +150,7 @@ memtest: ret .memfail: ; Say we failed (sadface) ; decrement hl the easy way - ld a,[hld] + dec [hl] push hl ld hl, failatstr call puts diff --git a/insn_ldm_a.v b/insn_ldm16_a.v similarity index 83% rename from insn_ldm_a.v rename to insn_ldm16_a.v index cd56b11..d8356f7 100644 --- a/insn_ldm_a.v +++ b/insn_ldm16_a.v @@ -13,9 +13,9 @@ `EXEC_READ(`_PC + 16'h0001) end 2: if (opcode[4]) // LD A,x - `EXEC_READ(({tmp, tmp2})) + `EXEC_READ(({rdata, tmp})) else - `EXEC_WRITE(({tmp, tmp2}), `_A) + `EXEC_WRITE(({rdata, tmp}), `_A) 3: begin `EXEC_NEWCYCLE `EXEC_INC_PC @@ -28,8 +28,8 @@ `INSN_LD16M_A: begin case (cycle) 0: begin end - 1: tmp2 <= rdata; - 2: tmp <= rdata; + 1: tmp <= rdata; + 2: begin end 3: if (opcode[4]) `_A <= rdata; endcase end diff --git a/insn_ldm8_a.v b/insn_ldm8_a.v new file mode 100644 index 0000000..2754862 --- /dev/null +++ b/insn_ldm8_a.v @@ -0,0 +1,32 @@ +// If opcode[4], then ld A, x, else ld x, A +// If opcode[1], then ld 16m8, else ld 8m8 + +`ifdef EXECUTE + `INSN_LD8M_A: begin + case (cycle) + 0: begin + `EXEC_INC_PC + `EXEC_READ(`_PC + 16'h0001) + end + 1: if (opcode[4]) // LD A,x + `EXEC_READ(({8'hFF, rdata})) + else + `EXEC_WRITE(({8'hFF, rdata}), `_A) + 2: begin + `EXEC_NEWCYCLE + `EXEC_INC_PC + end + endcase + end +`endif + +`ifdef WRITEBACK + `INSN_LD8M_A: begin + case (cycle) + 0: begin end + 2: begin end + 3: if (opcode[4]) `_A <= rdata; + endcase + end +`endif +