Experimentally use rst 1 to optimise frame variable loads. Reduces Star Trek

from 43892 to 43205 bytes.
This commit is contained in:
David Given 2019-02-07 00:06:32 +01:00
parent 08b92153a0
commit 5ac280026e
5 changed files with 63 additions and 8 deletions

29
mach/i80/libem/rst.s Normal file
View file

@ -0,0 +1,29 @@
#
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
.define .rst_init
.rst_init:
mvi a, 0xc3 ! jmp <a16>
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

View file

@ -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)}
#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
gen
dad lb
mov e,{m}
inx hl
mov d,{m} yields de
mov d,{m}
yields de
#endif
pat loe
uses hlreg

View file

@ -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

View file

@ -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 {

View file

@ -8,6 +8,9 @@ build_as {
build_ncg {
name = "ncg",
arch = "i80",
vars = {
["+cflags"] = "-DUSE_I80_RSTS"
}
}
build_top {