From 5ac280026e50ec85289d153ff4eaa04f0591c60b Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 7 Feb 2019 00:06:32 +0100 Subject: [PATCH] Experimentally use rst 1 to optimise frame variable loads. Reduces Star Trek from 43892 to 43205 bytes. --- mach/i80/libem/rst.s | 29 +++++++++++++++++++++++++++++ mach/i80/ncg/table | 28 +++++++++++++++++++++------- plat/cpm/boot.s | 6 ++++++ plat/cpm/build-pkg.lua | 5 ++++- plat/cpm/build-tools.lua | 3 +++ 5 files changed, 63 insertions(+), 8 deletions(-) create mode 100644 mach/i80/libem/rst.s diff --git a/mach/i80/libem/rst.s b/mach/i80/libem/rst.s new file mode 100644 index 000000000..b4ad39bee --- /dev/null +++ b/mach/i80/libem/rst.s @@ -0,0 +1,29 @@ +# +.sect .text +.sect .rom +.sect .data +.sect .bss +.sect .text + +.define .rst_init +.rst_init: + mvi a, 0xc3 ! jmp + sta 0x08 + lxi h, rst1 + shld 0x09 + ret + + ! de = [bc+const2] (remember bc is the frame pointer) +rst1: + pop h + mov e, m + inx h + mov d, m + inx h + push h + xchg ! hl = offset + dad b + mov e, m + inx h + mov d, m + ret diff --git a/mach/i80/ncg/table b/mach/i80/ncg/table index 0368b31e3..4101d2772 100644 --- a/mach/i80/ncg/table +++ b/mach/i80/ncg/table @@ -82,6 +82,8 @@ INSTRUCTIONS /* cpo label:ro cost(3,14). */ /* cz label:ro cost(3,14). */ /* daa kills a:cc cost(1, 4). */ + data1 ".data1" const1:ro. + data2 ".data2" const2:ro. dad b_d_h_sp:ro kills hl:cc cost(1,10). dcr reg+lbreg:rw:cc cost(1, 5). dcr m:rw:cc cost(1, 7). @@ -129,7 +131,7 @@ INSTRUCTIONS /* rpe cost(1, 8). */ /* rpo cost(1, 8). */ rrc kills a:cc cost(1, 4). -/* rst const1:ro cost(1,11). */ + rst const1:ro kills a:cc cost(1,11). /* rz cost(1, 8). */ sbb reg1:ro kills a:cc cost(1, 4). /* sbi const1:ro kills a:cc cost(2, 7). */ @@ -241,12 +243,24 @@ pat loc yields {const2,$1} pat ldc yields {const2,highw($1)} {const2,loww($1)} -pat lol -uses hlreg={const2,$1}, dereg -gen dad lb - mov e,{m} - inx hl - mov d,{m} yields de +#ifdef USE_I80_RSTS + pat lol + kills hlreg + uses hlreg, dereg + gen + rst {const1, 1} + data2 {const2, $1} + yields de +#else + pat lol + uses hlreg={const2, $1}, dereg + gen + dad lb + mov e,{m} + inx hl + mov d,{m} + yields de +#endif pat loe uses hlreg diff --git a/plat/cpm/boot.s b/plat/cpm/boot.s index 960dc400d..40ab0d775 100644 --- a/plat/cpm/boot.s +++ b/plat/cpm/boot.s @@ -48,6 +48,12 @@ begtext: lxi sp, stack + STACKSIZE + ! Initialise the rsts (if desired). + + #ifdef USE_I80_RSTS + call .rst_init + #endif + ! C-ify the command line at 0x0080. lxi h, 0x0080 diff --git a/plat/cpm/build-pkg.lua b/plat/cpm/build-pkg.lua index 0a4da3be0..59c9f806a 100644 --- a/plat/cpm/build-pkg.lua +++ b/plat/cpm/build-pkg.lua @@ -4,7 +4,10 @@ include("lang/build.lua") ackfile { name = "boot", srcs = { "./boot.s" }, - vars = { plat = "cpm" } + vars = { + plat = "cpm", + ["+ackcflags"] = "-DUSE_I80_RSTS", + } } build_plat_libs { diff --git a/plat/cpm/build-tools.lua b/plat/cpm/build-tools.lua index 383cf8c17..25d1b1327 100644 --- a/plat/cpm/build-tools.lua +++ b/plat/cpm/build-tools.lua @@ -8,6 +8,9 @@ build_as { build_ncg { name = "ncg", arch = "i80", + vars = { + ["+cflags"] = "-DUSE_I80_RSTS" + } } build_top {