optimizations

This commit is contained in:
mgcaret 2021-07-29 21:07:06 -07:00
parent c51b2b7db7
commit 8245ce322b
3 changed files with 84 additions and 45 deletions

View File

@ -4135,13 +4135,12 @@ cont: sta [WR]
sta [WR],y
lda WR
clc
adc #.loword(3)
adc #$0003 ; skip 3 more since we are dealing with words
sta WR
lda WR+2
adc #.hiword(3)
sta WR+2
bcc :+
inc WR+2
clc
rtl
: rtl
eword
; H: ( addr len -- ) Perform LWFLIP on the cells in memory.
@ -4708,8 +4707,9 @@ done: tya
adc XR+2
tay
lda WR+2
adc #$0000
jsr _pushay
bcc :+
inc a ; handle carry
: jsr _pushay
lda XR ; len of str 2 = XR-(XR+2)
sec
sbc XR+2
@ -4899,11 +4899,12 @@ dword rBODY,">BODY"
jmp _throway
: lda WR
clc
adc #$05
adc #$0005
tay
lda WR+2
adc #$00
PUSHNEXT
bcc :+
inc a
: PUSHNEXT
eword
; H: ( a-addr -- xt ) return xt of word with body at a-addr, if unable throw exc. -31
@ -7057,7 +7058,9 @@ lp: ONLIT 0 ; clear #LINE since we are at input prompt
eword
__doquit = QUIT::code
PLATFORM_INCLUDE "platform-words.s" ; Platform additional dictionary words
.if .strlen(PLATFORM) > 0
.include "platform-words.s" ; Platform additional dictionary words
.endif
; Leave these toward the top

View File

@ -56,31 +56,68 @@
.endif
.proc _next
inc IP ; inline fetch
bne :+
inc IP+2
: lda [IP] ; low word
tay
inc IP
bne :+
inc IP+2
: inc IP
bne :+
inc IP+2
: lda [IP] ; high word
inc IP
bne :+
.if 1
ldy #$0003 ; (3)/3
lda [IP],y ; (7)/2
.if !no_fast_lits
bne :++
jsr _stackdecr
sta STACKBASE+2,x
dey
dey
lda [IP],y
sta STACKBASE+0,x
lda IP
clc
adc #$0004
sta IP
bcc :+
inc IP+2
: bra _next
:
.endif
xba ; (3)/1 xxHH -> HHxx
pha ; (4)/1 stack ...HHxx
phb ; (3)/1 stack ...HHxxxx
dey ; (2)/1
dey ; (2)/1
lda [IP],y ; (7)/2 MMLL
sta 1,s ; (5)/2 stack ...HHMMLL
lda IP ; (4)/2
clc ; (2)/1
adc #$0004 ; (3)/2
sta IP ; (4)/2
bcc :+ ; (2)/2
inc IP+2 ; (6)/2
: rtl ; (6)/1 (63)/26
.else
; old implementation
inc IP ; (6)/2 inline fetch
bne :+ ; (2)/2
inc IP+2 ; (6)/2
: lda [IP] ; (7)/2 low word
tay ; (2)/1
inc IP ; (6)/2
bne :+ ; (2)/2
inc IP+2 ; (6)/2
: inc IP ; (6)/2
bne :+ ; (2)/2
inc IP+2 ; (6)/2
: lda [IP] ; (7)/2 high word
inc IP ; (6)/2
bne :+ ; (2)/2
inc IP+2 ; (6)/2 = (72)/29+run=(82)
:
.if !no_fast_lits
ora #$0000 ; faster than php+plp
beq fast_num
.endif
run: sep #SHORT_A
pha
rep #SHORT_A
phy
rtl
.endif
run: sep #SHORT_A ; (3)/1
pha ; (4)/1
rep #SHORT_A ; (3)/1
phy ; (4)/1
rtl ; (6)/1 = 20/5
fast_num: jsr _pushay
bra _next
.endproc

View File

@ -15,10 +15,10 @@
; Tunables
SPLIT_THRESH = 8 ; if block can be split and remainder have this many
; bytes + 6 bytes header, split it
MIN_BRK = $400 ; minimum break between DHERE and HIMEM in pages
MIN_BRK = $400 ; minimum break between DHERE and HIMEM in pages, 16 bit only
; Constants
HDR_SIZE = 6
HDR_SIZE = 6 ; 16 bits only
; Allocate XR bytes, return carry set+pointer in AY if successful
; or carry clear+AY=0 if unsuccessful
@ -54,9 +54,9 @@ grow: jsr _grow_heap
adc #.loword(HDR_SIZE)
tay
lda WR+2
clc
adc #.hiword(HDR_SIZE)
sec
bcc :+
inc a
: sec
rts
.endproc
@ -86,10 +86,9 @@ grow: jsr _grow_heap
clc
adc #.loword(HDR_SIZE)
sta YR
lda YR+2
adc #.hiword(HDR_SIZE)
sta YR+2 ; ok now YR points to child block
ldy #$04 ; first mark child block free
bcc :+
inc YR+2 ; ok now YR points to child block
: ldy #$04 ; first mark child block free
lda #$0000 ; by zeroing its flags
sta [YR],y
dey
@ -284,16 +283,16 @@ none: pla ; drop the block pointer
sec
sbc #.loword(HDR_SIZE)
sta YR
lda YR+2
sbc #.hiword(HDR_SIZE)
sta YR+2
lda DHERE ; now compare to DHERE+minimum break
bcs :+
dec YR+2
: lda DHERE ; now compare to DHERE+minimum break
clc
adc #.loword(MIN_BRK)
tay
lda DHERE+2
adc #.hiword(MIN_BRK)
cmp YR+2
bcc :+
inc a
: cmp YR+2
bne :+
tya
cmp YR