From 70bc8883020a2da4326439a8308513a7385dc568 Mon Sep 17 00:00:00 2001 From: Duncan Smith Date: Mon, 6 Sep 2010 18:09:29 -0700 Subject: Fixes to actually run code This is the version to run the first (trivial) infinite loop correctly. I hacked up the loader slightly to replace one of the (nonexistent) pages with a static byte array. z80 code executed: $4000: JP $4000 4000 c3 40 00 4003 This version also draws the opcode executed on the screen, to aid in debugging the emulator: move.b d0,$4c00+32*(128/8) Also, it turns out that I was mixing up the emulated SP (a4) and emulated PC (a6). That has been fixed. Further, it seems that movea defaults to a word operation in a68k. This led to pointer corruption, which has been fixed. --- 680.h | 0 loader.c | 7 +++++-- main.asm | 4 ++-- misc.c | 17 +++++++++++++++++ opcodes.asm | 13 +++++++------ 5 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 680.h create mode 100644 misc.c diff --git a/680.h b/680.h new file mode 100644 index 0000000..e69de29 diff --git a/loader.c b/loader.c index 56561c0..97f2d4c 100644 --- a/loader.c +++ b/loader.c @@ -8,9 +8,11 @@ #include #include "asm_vars.h" +#include "680.h" + HANDLE page_handles[256]; -char infloop[16] = { 0xc3, 0, 0, 0 }; +char infloop[16] = { 0xC3, 0x40, 0, 0, 0, 0 }; void init_load(void); void *deref_page(int); @@ -55,7 +57,8 @@ void init_load(void) mem_page_0 = pages[0]; mem_page_loc_0 = 0; - mem_page_1 = pages[0x1f]; +// mem_page_1 = pages[0x1f]; + mem_page_1 = infloop; mem_page_loc_1 = 0x1f; mem_page_2 = pages[0]; mem_page_loc_2 = 0; diff --git a/main.asm b/main.asm index 9a4789f..e6f2a54 100644 --- a/main.asm +++ b/main.asm @@ -66,8 +66,8 @@ emu_setup: lea flag_storage,a3 move.w #$4000,d1 bsr deref - move a0,a6 - move a0,a4 + move.l a0,a6 + move.l a0,a4 rts diff --git a/misc.c b/misc.c new file mode 100644 index 0000000..9224145 --- /dev/null +++ b/misc.c @@ -0,0 +1,17 @@ +/* Miscellaneous C routines for 680 project. + * + * Error handling, for now. + * + * Copyright 2010, Duncan Smith + * GPL + */ + +#include +#include "asm_vars.h" + +/* SOMETHING WENT HORRIBLY HORRIBLY WRONG + */ +void throw_error(char *message) +{ + return; +} diff --git a/opcodes.asm b/opcodes.asm index fe5547c..8042296 100644 --- a/opcodes.asm +++ b/opcodes.asm @@ -108,7 +108,8 @@ _align SET _align+$20 ;; This is run at the end of every instruction routine. DONE MACRO clr.w d0 ; 4 cycles / 2 bytes - move.b (a4)+,d0 ; 8 cycles / 2 bytes + move.b (a6)+,d0 ; 8 cycles / 2 bytes + move.b d0,$4c00+32*(128/8) rol.w #5,d0 ;16 cycles / 2 bytes jmp 0(a5,d0.w) ;14 cycles / 4 bytes ;; overhead: 42 cycles /10 bytes @@ -602,7 +603,7 @@ emu_op_31: ;; LD SP,immed.w FETCHWI d1 bsr deref - movea a0,a4 + movea.l a0,a4 DONE START @@ -1792,7 +1793,7 @@ emu_op_c3: ; S12 T36 ;; PC <- immed.w FETCHWI d1 bsr deref - movea a0,a6 + movea.l a0,a6 DONE START @@ -1844,7 +1845,7 @@ emu_op_c9: ;; SP <- (SP+2) POPW d1 bsr deref - movea a0,a6 + movea.l a0,a6 DONE START @@ -2095,7 +2096,7 @@ emu_op_e9: ;; JP (HL) FETCHB d6,d1 bsr deref - movea a0,a6 + movea.l a0,a6 DONE START @@ -2225,7 +2226,7 @@ emu_op_f9: ;; SP <- HL move.w d6,d1 bsr deref - movea a0,a4 + movea.l a0,a4 DONE START -- cgit v1.2.3