summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Smith2010-09-07 19:12:01 -0700
committerDuncan Smith2010-09-07 19:12:01 -0700
commitdbe094eeae873ff5788b99d8a9c763df963d3a30 (patch)
treeadc7d83bc7634d4dc8aeab8f7955ed8fd452c7ec
parentc4f950804cbf98ffb2ec6eef4928e1795132df83 (diff)
IO port framework now works
A68k is defaulting all my address moves to word size, rather than long. I don't know whether I've expunged all this nonsense yet, but I'm trying. This version executes an infinite loop which writes 'A' to port 00h. I've patched in a write-to-console function on port 00h, so this can be used as a sort of debug monitor.
-rw-r--r--680.inc4
-rw-r--r--Makefile2
-rw-r--r--debug.c14
-rw-r--r--loader.c9
-rw-r--r--ports.asm20
5 files changed, 42 insertions, 7 deletions
diff --git a/680.inc b/680.inc
index 3578ea9..20f3bed 100644
--- a/680.inc
+++ b/680.inc
@@ -11,11 +11,11 @@ ehl EQUR d6
eixy EQUR d7
SAVEREG MACRO
- movem d3-d7/a3-a6,-(sp)
+ movem.l d3-d7/a3-a6,-(sp)
ENDM
RESTREG MACRO
- movem (sp)+,d3-d7/a3-a6
+ movem.l (sp)+,d3-d7/a3-a6
ENDM
;; pushm MACRO
diff --git a/Makefile b/Makefile
index 262bfe3..f3bb30f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
ASM_FILES=alu.asm flags.asm opcodes.asm ports.asm interrupts.asm main.asm
ASM=main.asm
-C_FILES=loader.c bankswap.c video.c misc.c
+C_FILES=loader.c bankswap.c video.c misc.c debug.c
TIGCCFLAGS=-Wall
CFLAGS=-Wall -ltifiles
diff --git a/debug.c b/debug.c
new file mode 100644
index 0000000..332ae16
--- /dev/null
+++ b/debug.c
@@ -0,0 +1,14 @@
+/* Debugging routines for 680 project.
+ *
+ * Includes debug output.
+ *
+ * Copyright 2010, Duncan Smith
+ * GPL
+ */
+
+#include <stdio.h>
+
+void char_draw(char c)
+{
+ putchar((short)c);
+}
diff --git a/loader.c b/loader.c
index 97f2d4c..75654f4 100644
--- a/loader.c
+++ b/loader.c
@@ -12,7 +12,12 @@
HANDLE page_handles[256];
-char infloop[16] = { 0xC3, 0x40, 0, 0, 0, 0 };
+char infloop[16] = { 0xC3, 0x40, // JP 4000h
+ 0, 0, 0, 0 };
+char writestr[16] = { 0x3E, 0x41, // LD A,'A'
+ 0xD3, 0x00, // OUT 00h,A
+ 0xC3, 0x40, 0x00 // JP 4000h
+};
void init_load(void);
void *deref_page(int);
@@ -58,7 +63,7 @@ void init_load(void)
mem_page_0 = pages[0];
mem_page_loc_0 = 0;
// mem_page_1 = pages[0x1f];
- mem_page_1 = infloop;
+ mem_page_1 = writestr;
mem_page_loc_1 = 0x1f;
mem_page_2 = pages[0];
mem_page_loc_2 = 0;
diff --git a/ports.asm b/ports.asm
index 5834ae5..c7b43e4 100644
--- a/ports.asm
+++ b/ports.asm
@@ -4,7 +4,10 @@
;; Port is in d0, byte is in d1
;; Destroys a0
port_in:
- movea lut_ports_in(pc,d0),a0
+ andi.w #$ff,d0
+ add.w d0,d0
+ add.w d0,d0
+ movea.l lut_ports_in(pc,d0),a0
jmp (a0)
rts
@@ -267,7 +270,10 @@ lut_ports_in:
dc.l port_in_ff
port_out:
- movea lut_ports_out(pc,d0.w),a0
+ andi.w #$ff,d0
+ add.w d0,d0
+ add.w d0,d0
+ movea.l lut_ports_out(pc,d0.w),a0
jmp (a0)
rts
@@ -531,6 +537,16 @@ lut_ports_out:
port_in_00:
port_out_00:
+ ;; Temporary test harness. Writing to this port writes a
+ ;; character to the screen.
+ SAVEREG
+ andi.w #$ff,d1
+ move.w d1,-(sp)
+ jsr char_draw
+ addq #2,sp
+ RESTREG
+ rts
+
port_in_01:
port_out_01:
port_in_02: