From 447fde2ff635163dea17c07a13c5d2673674b9f8 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sun, 25 Oct 2015 21:45:19 +0000 Subject: [PATCH] z80: framework for RST shortening of function preamble 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 | 5 +++-- Kernel/cpu-z80/rst8.peep | 10 ++++++++++ Kernel/platform-micropack/rules.mk | 5 +++++ Kernel/platform-micropack/z80pack.s | 9 +++++++++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 Kernel/cpu-z80/rst8.peep create mode 100644 Kernel/platform-micropack/rules.mk diff --git a/Kernel/Makefile b/Kernel/Makefile index ed270642..8049680e 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -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 index 00000000..6acee5b2 --- /dev/null +++ b/Kernel/cpu-z80/rst8.peep @@ -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 index 00000000..5b2f4a14 --- /dev/null +++ b/Kernel/platform-micropack/rules.mk @@ -0,0 +1,5 @@ +# +# Use RST8 for call preamble +# +CROSS_CCOPTS += --peep-file $(ROOT_DIR)/cpu-z80/rst8.peep + diff --git a/Kernel/platform-micropack/z80pack.s b/Kernel/platform-micropack/z80pack.s index f5a096b3..d1a294a9 100644 --- a/Kernel/platform-micropack/z80pack.s +++ b/Kernel/platform-micropack/z80pack.s @@ -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 -- 2.34.1