resolve #6; general clean-up

This commit is contained in:
mgcaret 2020-01-04 16:25:41 -08:00
parent 7f57ba6f06
commit 32ec1e9df4
4 changed files with 41 additions and 90 deletions

View File

@ -3102,7 +3102,7 @@ getbuf: lda [SYSVARS],y ; get buffer pointer
setbuf1: ldy #SV_SBUF1 ; select buf 1
setbuf: pla ; update pointers
sta YR ; in YR
sta [SYSVARS],y ; in the appropriate system var
sta [SYSVARS],y ; in the appropriate system var
sta STACKBASE+4,x ; in the parameter stack
iny
iny
@ -3110,7 +3110,8 @@ setbuf: pla ; update pointers
sta YR+2
sta [SYSVARS],y
sta STACKBASE+6,x
jsr _move
sec ; move down is faster
jsr _memmove
NEXT
nomem: ldy #.loword(-18)
lda #.hiword(-18)
@ -3779,7 +3780,7 @@ dword MOVE,"MOVE"
jsr _popxr
jsr _popyr
jsr _popwr
jsr _move
jsr _memmove
NEXT
eword
@ -3793,7 +3794,8 @@ dword CMOVEUP,"CMOVE>"
jsr _popxr
jsr _popyr
jsr _popwr
jsr _moveup
clc
jsr _memmove_c
NEXT
eword
@ -4483,7 +4485,8 @@ dword PACK,"PACK"
inc YR
bne :+
inc YR+2
: jsr _move
: sec ; move down is faster
jsr _memmove_c
NEXT
bad: ldy #.loword(-18)
lda #.hiword(-18)
@ -5396,7 +5399,8 @@ hword SCONCAT,"SCONCAT"
lda XR+2
adc STACKBASE+2,x
sta STACKBASE+2,x
jsr _move ; move the string
sec ; move down is faster
jsr _memmove_c ; move the string
NEXT
eword

View File

@ -899,72 +899,6 @@ good: sec
.endproc
.a16
; Move XR bytes from [WR] to [YR], starting at the bottom
; trashes WR, YR, and XR
; could be optimized to move words, excepting the last one if odd number of bytes
; use for moving data downward, but that adds two comparison instructions which
; are slower than the SEP/REP, maybe
.proc _move
.if 1 ; fast move in memmgr.s
sec
jmp _memmove_c
.else ; slower but smaller move
lp: lda XR+2 ; see if zero bytes
ora XR
bne :+
rts
: jsr _decxr ; pre-decrement XR
sep #SHORT_A
lda [WR]
sta [YR]
rep #SHORT_A
jsr _incwr ; post increment WR
inc YR ; and YR
bne lp
inc YR+2
bra lp
.endif
.endproc
; Move XR bytes from [WR] to [YR], starting at the top
; trashes YR and XR
; could be optimized to move words, excepting the last one if odd number of bytes
; use for moving data upward
.proc _moveup
.if 1 ; fast move in memmgr.s
clc
jmp _memmove_c
.else ; slower but smaller move
lp: jsr _wrplusxr
lda WR ; move WR to 1 past the end of the block
clc
adc XR
sta WR
lda WR+2
adc XR+2
sta WR+2
lda YR ; move YR to 1 past the end of the block
clc
adc XR
sta YR
lda YR+2
adc XR+2
sta YR+2
lda XR+2
ora XR
bne :+
rts
: jsr _decxr ; decrement XR
jsr _decwr ; and WR
jsr _decyr ; and YR
sep #SHORT_A
lda [WR]
sta [YR]
rep #SHORT_A
bra lp
.endif
.endproc
; With word header address in YR, set YR to previous dictionary entry header
; return with Z flag set if the new address is zero
.proc _prevword

View File

@ -20,6 +20,7 @@ samesign: lda STACKBASE+6,x
cmp STACKBASE+0,x
: rts
.endproc
_test32 = _stest32::samesign
.proc _invertay
pha

View File

@ -419,17 +419,16 @@ loop: jsr _chk_himem
done: rts
.endproc
.if 1 ; include fast memory move routines
; Memory move routines
; move XR bytes of memory from [WR] to [YR]
; Move appropriately based
; Move appropriately based on source and destination
.proc _memmove
lda WR
cmp YR
lda WR+2
sbc YR+2
; now carry is set if WR >= XR, move down in that case, otherwise move up
; now carry is set if WR >= YR, move down in that case, otherwise move up
; fall-through
.endproc
@ -509,7 +508,7 @@ md6: pha
jsl f:_callzr
plb
pla
eor #$ffff ; a xor $ffff = $ffff - a = -1 - a
eor #$FFFF ; a xor $FFFF = $FFFF - a = -1 - a
adc sizel
sta sizel ; sizel = sizel - 1 - a
sep #$20
@ -517,10 +516,9 @@ md6: pha
lda sizeh ; update high byte of size
sbc #$00
bcs md1
rep #$30
plp
.a16
.i16
plp
plx
rts
.endproc
@ -533,11 +531,27 @@ tol = YR
sizeh = XR+2
sizel = XR
mu7 = ZR
; first convert start addresses to end addresses
lda WR
clc
adc XR
sta WR
lda WR+2
adc XR+2
sta WR+2
lda YR
clc
adc XR
sta YR
lda YR+2
adc XR+2
sta YR+2
; now start the move
phx
php
lda #$6B00 ; RTL
sta mu7+2
lda #$0054 ; MVN
lda #$0044 ; MVP
sta mu7
sep #$21 ; 8-bit accumulator, set carry
.a8
@ -557,25 +571,25 @@ mu7 = ZR
cmp froml
bcs mu3
bra mu4
.a8
.a8 ; a is 8 bits when we branch to mu1!
mu1: sta sizeh
eor #$80 ; set v if size is zero, clear v otherwise
eor #$80 ; set v if size is zero, clear v otherwise
sbc #$01
cpx #$FFFF
bne mu2 ; if x is not $FFFF, then y must be
bne mu2 ; if x is not $FFFF, then y must be
dec mu7+2
rep #$20
.a16
tya
cpy #$FFFF
bne mu4
.a8
sep #$20
.a8
mu2: dec mu7+1
rep #$20
.a16
mu3: txa
mu4: bvc mu5 ; branch if sizeh is nonzero
mu4: bvc mu5 ; branch if sizeh is nonzero
cmp sizel
bcc mu6
lda sizel
@ -585,18 +599,17 @@ mu6: pha
jsl f:_callzr
plb
pla
eor #$FFFF ; a xor $FFFF = $FFFF - a = -1 - a
eor #$FFFF ; a xor $FFFF = $FFFF - a = -1 - a
adc sizel
sta sizel ; sizel = sizel - 1 - a
sta sizel ; sizel = sizel - 1 - a
sep #$20
.a8
lda sizeh ; update high byte of size
lda sizeh ; update high byte of size
sbc #$00
bcs mu1
rep #$30
plp
.a16
.i16
plp
plx
rts
.endproc
@ -623,4 +636,3 @@ mu6: pha
pla ; ( 0 zrh zrl ah al -- 0 zrh zrl )
rtl ; ( 0 zrh zrl -- )
.endproc
.endif