z80: framework for RST shortening of function preamble
authorAlan Cox <alan@etchedpixels.co.uk>
Sun, 25 Oct 2015 21:45:19 +0000 (21:45 +0000)
committerAlan Cox <alan@etchedpixels.co.uk>
Sun, 25 Oct 2015 21:45:19 +0000 (21:45 +0000)
Another 200 bytes. Need to think harder about what RST to ultimately use to
avoid mucking up CP/M emulator, and would be good to keep it a common value
so most platform userspace can also use the same hook

Kernel/Makefile
Kernel/cpu-z80/rst8.peep [new file with mode: 0644]
Kernel/platform-micropack/rules.mk [new file with mode: 0644]
Kernel/platform-micropack/z80pack.s

index ed27064..8049680 100644 (file)
@@ -9,7 +9,7 @@ TARGET_LIST = platform-nc100 platform-micropack platform-pcw8256 platform-socz80
 #export TARGET = coco2
 #export TARGET = coco3
 #export TARGET = dragon-nx32
-#export TARGET = micropack
+export TARGET = micropack
 #export TARGET = msx1
 #export TARGET = msx2
 #export TARGET = mtx
@@ -21,7 +21,7 @@ TARGET_LIST = platform-nc100 platform-micropack platform-pcw8256 platform-socz80
 #export TARGET = px4plus
 #export TARGET = socz80
 #export TARGET = tgl6502
-export TARGET = trs80
+#export TARGET = trs80
 #export TARGET = ubee
 #export TARGET = z80pack
 #export TARGET = z80pack-lite
@@ -30,6 +30,7 @@ export TARGET = trs80
 
 export VERSION = "0.1"
 export SUBVERSION = "ac1"
+export ROOT_DIR
 
 ifeq ($(MAKE),)
   export MAKE = "make"
diff --git a/Kernel/cpu-z80/rst8.peep b/Kernel/cpu-z80/rst8.peep
new file mode 100644 (file)
index 0000000..6acee5b
--- /dev/null
@@ -0,0 +1,10 @@
+;
+;      Convert the function preambles calls into RST8
+;
+replace restart        {
+       call    ___sdcc_enter_ix
+} by {
+       rst 8
+}
+
+
diff --git a/Kernel/platform-micropack/rules.mk b/Kernel/platform-micropack/rules.mk
new file mode 100644 (file)
index 0000000..5b2f4a1
--- /dev/null
@@ -0,0 +1,5 @@
+#
+#      Use RST8 for call preamble
+#
+CROSS_CCOPTS += --peep-file $(ROOT_DIR)/cpu-z80/rst8.peep
+
index f5a096b..d1a294a 100644 (file)
@@ -31,6 +31,8 @@
             .globl outchar
 
             ; imported symbols
+
+           .globl ___sdcc_enter_ix
             .globl _ramsize
             .globl _procmem
 
@@ -114,6 +116,13 @@ _program_vectors:
             ld hl, #interrupt_handler
             ld (0x0039), hl
 
+            ; RST8 helper
+            ld a, #0xC3 ; JP instruction
+            ld (0x008), a
+            ld hl, #___sdcc_enter_ix
+
+            ld (0x009), hl
+
             ; set restart vector for UZI system calls
             ld (0x0030), a   ;  (rst 30h is unix function call vector)
             ld hl, #unix_syscall_entry