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)
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 \
--- /dev/null
+#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