v8080: add the compiler helper restarts
authorAlan Cox <alan@linux.intel.com>
Sat, 9 Feb 2019 23:17:15 +0000 (23:17 +0000)
committerAlan Cox <alan@linux.intel.com>
Sat, 9 Feb 2019 23:17:15 +0000 (23:17 +0000)
Kernel/platform-v8080/Makefile
Kernel/platform-v8080/rst.s [new file with mode: 0644]
Kernel/platform-v8080/v8080.s

index 445cdd2..03641a6 100644 (file)
@@ -3,7 +3,7 @@ LIBC=$(LIBPATH)/libc8080.a $(ACK_ROOT)/share/ack/cpm/libem.a
 
 CSRCS += devices.c main.c devtty.c devfd.c
 
-ASRCS = crt0.s commonmem.s v8080.s tricks.s end.s
+ASRCS = crt0.s commonmem.s v8080.s tricks.s rst.s end.s
 
 AOBJS = $(ASRCS:.s=.o)
 COBJS = $(CSRCS:.c=.o)
@@ -30,7 +30,7 @@ bootblock:
 
 image: bootblock
        $(CROSS_LD) -b0:0x0100 -b4:0xE800 -o fuzix.bin crt0.o devices.o main.o \
-       commonmem.o tricks.o v8080.o devtty.o \
+       commonmem.o tricks.o v8080.o rst.o devtty.o \
        ../start.o ../version.o ../lowlevel-8080.o \
        ../bankfixed.o ../timer.o ../kdata.o  \
        ../devio.o ../filesys.o ../process.o ../inode.o ../syscall_fs.o \
diff --git a/Kernel/platform-v8080/rst.s b/Kernel/platform-v8080/rst.s
new file mode 100644 (file)
index 0000000..28117b2
--- /dev/null
@@ -0,0 +1,75 @@
+#include "../kernel-8080.def"
+
+.sect .common
+!
+!      We need this in common because
+!      1. We need to use .rst_init to install the hooks in other banks
+!      2. User space also shares these rst handlers (why store them
+!      repeatedly). That does create an ABI concern but if it becomes a
+!      problem we just make user apps override
+!
+.define .rst_init
+.rst_init:
+    mvi a, 0xc3     ! jmp <a16>
+    sta 0x08
+    sta 0x10
+    sta 0x18
+    lxi h, rst1
+    shld 0x09
+    lxi h, rst2
+    shld 0x11
+    lxi h, rst3
+    shld 0x19
+    ret
+
+    ! de = [bc+const1] (remember bc is the frame pointer)
+rst1:
+    pop h
+    mov a, m
+    inx h
+    push h
+
+       mov l, a
+       ral
+       sbb a
+       mov h, a
+
+       dad b
+    mov e, m
+    inx h
+    mov d, m
+    ret
+
+    ! [bc+const1] = de (remember bc is the frame pointer)
+rst2:
+    pop h
+    mov a, m
+    inx h
+    push h
+
+       mov l, a
+       ral
+       sbb a
+       mov h, a
+
+       dad b
+    mov m, e
+    inx h
+    mov m, d
+    ret
+
+    ! hl = bc+const1
+rst3:
+    pop h
+    mov a, m
+    inx h
+    push h
+
+    mov l, a
+    ral
+    sbb a
+    mov h, a
+
+    dad b
+    ret
+    
\ No newline at end of file
index 8b55237..507e544 100644 (file)
@@ -25,7 +25,8 @@ platform_interrupt_all:
 .define init_early
 
 init_early:
-       ret
+       jmp .rst_init
+
 
 .define init_hardware
 
@@ -72,7 +73,7 @@ _program_vectors_k:
        shld 0x31
        lxi h,nmi_handler
        shld 0x67
-       ret
+       jmp .rst_init
 
 !
 !      Memory mapping