mirror of
https://github.com/mgcaret/of816.git
synced 2024-05-28 14:41:27 +00:00
resolve #6; general clean-up
This commit is contained in:
parent
7f57ba6f06
commit
32ec1e9df4
|
@ -3102,7 +3102,7 @@ getbuf: lda [SYSVARS],y ; get buffer pointer
|
||||||
setbuf1: ldy #SV_SBUF1 ; select buf 1
|
setbuf1: ldy #SV_SBUF1 ; select buf 1
|
||||||
setbuf: pla ; update pointers
|
setbuf: pla ; update pointers
|
||||||
sta YR ; in YR
|
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
|
sta STACKBASE+4,x ; in the parameter stack
|
||||||
iny
|
iny
|
||||||
iny
|
iny
|
||||||
|
@ -3110,7 +3110,8 @@ setbuf: pla ; update pointers
|
||||||
sta YR+2
|
sta YR+2
|
||||||
sta [SYSVARS],y
|
sta [SYSVARS],y
|
||||||
sta STACKBASE+6,x
|
sta STACKBASE+6,x
|
||||||
jsr _move
|
sec ; move down is faster
|
||||||
|
jsr _memmove
|
||||||
NEXT
|
NEXT
|
||||||
nomem: ldy #.loword(-18)
|
nomem: ldy #.loword(-18)
|
||||||
lda #.hiword(-18)
|
lda #.hiword(-18)
|
||||||
|
@ -3779,7 +3780,7 @@ dword MOVE,"MOVE"
|
||||||
jsr _popxr
|
jsr _popxr
|
||||||
jsr _popyr
|
jsr _popyr
|
||||||
jsr _popwr
|
jsr _popwr
|
||||||
jsr _move
|
jsr _memmove
|
||||||
NEXT
|
NEXT
|
||||||
eword
|
eword
|
||||||
|
|
||||||
|
@ -3793,7 +3794,8 @@ dword CMOVEUP,"CMOVE>"
|
||||||
jsr _popxr
|
jsr _popxr
|
||||||
jsr _popyr
|
jsr _popyr
|
||||||
jsr _popwr
|
jsr _popwr
|
||||||
jsr _moveup
|
clc
|
||||||
|
jsr _memmove_c
|
||||||
NEXT
|
NEXT
|
||||||
eword
|
eword
|
||||||
|
|
||||||
|
@ -4483,7 +4485,8 @@ dword PACK,"PACK"
|
||||||
inc YR
|
inc YR
|
||||||
bne :+
|
bne :+
|
||||||
inc YR+2
|
inc YR+2
|
||||||
: jsr _move
|
: sec ; move down is faster
|
||||||
|
jsr _memmove_c
|
||||||
NEXT
|
NEXT
|
||||||
bad: ldy #.loword(-18)
|
bad: ldy #.loword(-18)
|
||||||
lda #.hiword(-18)
|
lda #.hiword(-18)
|
||||||
|
@ -5396,7 +5399,8 @@ hword SCONCAT,"SCONCAT"
|
||||||
lda XR+2
|
lda XR+2
|
||||||
adc STACKBASE+2,x
|
adc STACKBASE+2,x
|
||||||
sta STACKBASE+2,x
|
sta STACKBASE+2,x
|
||||||
jsr _move ; move the string
|
sec ; move down is faster
|
||||||
|
jsr _memmove_c ; move the string
|
||||||
NEXT
|
NEXT
|
||||||
eword
|
eword
|
||||||
|
|
||||||
|
|
|
@ -899,72 +899,6 @@ good: sec
|
||||||
.endproc
|
.endproc
|
||||||
.a16
|
.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
|
; With word header address in YR, set YR to previous dictionary entry header
|
||||||
; return with Z flag set if the new address is zero
|
; return with Z flag set if the new address is zero
|
||||||
.proc _prevword
|
.proc _prevword
|
||||||
|
|
|
@ -20,6 +20,7 @@ samesign: lda STACKBASE+6,x
|
||||||
cmp STACKBASE+0,x
|
cmp STACKBASE+0,x
|
||||||
: rts
|
: rts
|
||||||
.endproc
|
.endproc
|
||||||
|
_test32 = _stest32::samesign
|
||||||
|
|
||||||
.proc _invertay
|
.proc _invertay
|
||||||
pha
|
pha
|
||||||
|
|
48
asm/memmgr.s
48
asm/memmgr.s
|
@ -419,17 +419,16 @@ loop: jsr _chk_himem
|
||||||
done: rts
|
done: rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
.if 1 ; include fast memory move routines
|
|
||||||
; Memory move routines
|
; Memory move routines
|
||||||
; move XR bytes of memory from [WR] to [YR]
|
; move XR bytes of memory from [WR] to [YR]
|
||||||
|
|
||||||
; Move appropriately based
|
; Move appropriately based on source and destination
|
||||||
.proc _memmove
|
.proc _memmove
|
||||||
lda WR
|
lda WR
|
||||||
cmp YR
|
cmp YR
|
||||||
lda WR+2
|
lda WR+2
|
||||||
sbc YR+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
|
; fall-through
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
@ -509,7 +508,7 @@ md6: pha
|
||||||
jsl f:_callzr
|
jsl f:_callzr
|
||||||
plb
|
plb
|
||||||
pla
|
pla
|
||||||
eor #$ffff ; a xor $ffff = $ffff - a = -1 - a
|
eor #$FFFF ; a xor $FFFF = $FFFF - a = -1 - a
|
||||||
adc sizel
|
adc sizel
|
||||||
sta sizel ; sizel = sizel - 1 - a
|
sta sizel ; sizel = sizel - 1 - a
|
||||||
sep #$20
|
sep #$20
|
||||||
|
@ -517,10 +516,9 @@ md6: pha
|
||||||
lda sizeh ; update high byte of size
|
lda sizeh ; update high byte of size
|
||||||
sbc #$00
|
sbc #$00
|
||||||
bcs md1
|
bcs md1
|
||||||
rep #$30
|
plp
|
||||||
.a16
|
.a16
|
||||||
.i16
|
.i16
|
||||||
plp
|
|
||||||
plx
|
plx
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -533,11 +531,27 @@ tol = YR
|
||||||
sizeh = XR+2
|
sizeh = XR+2
|
||||||
sizel = XR
|
sizel = XR
|
||||||
mu7 = ZR
|
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
|
phx
|
||||||
php
|
php
|
||||||
lda #$6B00 ; RTL
|
lda #$6B00 ; RTL
|
||||||
sta mu7+2
|
sta mu7+2
|
||||||
lda #$0054 ; MVN
|
lda #$0044 ; MVP
|
||||||
sta mu7
|
sta mu7
|
||||||
sep #$21 ; 8-bit accumulator, set carry
|
sep #$21 ; 8-bit accumulator, set carry
|
||||||
.a8
|
.a8
|
||||||
|
@ -557,25 +571,25 @@ mu7 = ZR
|
||||||
cmp froml
|
cmp froml
|
||||||
bcs mu3
|
bcs mu3
|
||||||
bra mu4
|
bra mu4
|
||||||
.a8
|
.a8 ; a is 8 bits when we branch to mu1!
|
||||||
mu1: sta sizeh
|
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
|
sbc #$01
|
||||||
cpx #$FFFF
|
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
|
dec mu7+2
|
||||||
rep #$20
|
rep #$20
|
||||||
.a16
|
.a16
|
||||||
tya
|
tya
|
||||||
cpy #$FFFF
|
cpy #$FFFF
|
||||||
bne mu4
|
bne mu4
|
||||||
.a8
|
|
||||||
sep #$20
|
sep #$20
|
||||||
|
.a8
|
||||||
mu2: dec mu7+1
|
mu2: dec mu7+1
|
||||||
rep #$20
|
rep #$20
|
||||||
.a16
|
.a16
|
||||||
mu3: txa
|
mu3: txa
|
||||||
mu4: bvc mu5 ; branch if sizeh is nonzero
|
mu4: bvc mu5 ; branch if sizeh is nonzero
|
||||||
cmp sizel
|
cmp sizel
|
||||||
bcc mu6
|
bcc mu6
|
||||||
lda sizel
|
lda sizel
|
||||||
|
@ -585,18 +599,17 @@ mu6: pha
|
||||||
jsl f:_callzr
|
jsl f:_callzr
|
||||||
plb
|
plb
|
||||||
pla
|
pla
|
||||||
eor #$FFFF ; a xor $FFFF = $FFFF - a = -1 - a
|
eor #$FFFF ; a xor $FFFF = $FFFF - a = -1 - a
|
||||||
adc sizel
|
adc sizel
|
||||||
sta sizel ; sizel = sizel - 1 - a
|
sta sizel ; sizel = sizel - 1 - a
|
||||||
sep #$20
|
sep #$20
|
||||||
.a8
|
.a8
|
||||||
lda sizeh ; update high byte of size
|
lda sizeh ; update high byte of size
|
||||||
sbc #$00
|
sbc #$00
|
||||||
bcs mu1
|
bcs mu1
|
||||||
rep #$30
|
plp
|
||||||
.a16
|
.a16
|
||||||
.i16
|
.i16
|
||||||
plp
|
|
||||||
plx
|
plx
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
@ -623,4 +636,3 @@ mu6: pha
|
||||||
pla ; ( 0 zrh zrl ah al -- 0 zrh zrl )
|
pla ; ( 0 zrh zrl ah al -- 0 zrh zrl )
|
||||||
rtl ; ( 0 zrh zrl -- )
|
rtl ; ( 0 zrh zrl -- )
|
||||||
.endproc
|
.endproc
|
||||||
.endif
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user