]> Joshua Wise's Git repositories - fpgaboy.git/commitdiff
Fix ld [] and ld []
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Tue, 15 Apr 2008 05:09:02 +0000 (01:09 -0400)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Tue, 15 Apr 2008 05:09:02 +0000 (01:09 -0400)
Makefile
allinsns.v
diag.asm
insn_ldm16_a.v [moved from insn_ldm_a.v with 83% similarity]
insn_ldm8_a.v [new file with mode: 0644]

index 9751d4eaf9525de03ac0317858e6b4d1aa1c7efd..3cabf3feb3cf9792ec6fefe51d7bcb9cf44870b6 100644 (file)
--- 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
 
index 3097f3d62f22515fd44d0acde59f98e00ad3f607..8d33aa296e8d50e930dbfd306f040a7fa1214926 100644 (file)
@@ -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"
index 80164004fea23ecde8dc9fcdd67c005c506978de..8e09874baaf06cdb9b6472508f81a2cbff6a8dda 100644 (file)
--- 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
similarity index 83%
rename from insn_ldm_a.v
rename to insn_ldm16_a.v
index cd56b11434cc19aa497ddfa8411507d82f337a51..d8356f76862a633a0fb3ae1bd76df27b3e8210b9 100644 (file)
@@ -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 (file)
index 0000000..2754862
--- /dev/null
@@ -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
+
This page took 0.031132 seconds and 4 git commands to generate.