#include "../kernel-8080.def"
+.sect .text
+
+! Which resets we install are determined by statistical analysis of Star
+! Trek. When changing these, make sure to update the i80 table to match.
+! 97 call .floadn2
+! 41 call .floadn4
+! 34 call .fload4
+! 28 call .fstoren2
-.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
+ lxi h, .floadn2
+ lxi d, 0x0008
+ call copy
+ lxi h, .floadn4
+ call copy
+ lxi h, .fload4
+ call copy
+ lxi h, .fstoren2
+! Copies eight bytes from HL to DE.
+copy:
+ mvi c, 8
+.1:
mov a, m
+ stax d
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
+ inr e
+ dcr c
+ jnz .1
+ ret
\ No newline at end of file