AppleIIAsm-Collection/source/disk2_common/T.MIN.SUB.MEMMOVE

102 lines
2.1 KiB
Plaintext
Raw Normal View History

MEMMOVE
PLA
STA RETADR
PLA
STA RETADR+1
PLA
STA :MVELEN
PLA
STA :MVELEN+1
PLA
STA ADDR2
PLA
STA ADDR2+1
PLA
STA ADDR1
PLA
STA ADDR1+1
LDA ADDR2 ;CALC DEST-SRC
SEC
SBC ADDR1
TAX
LDA ADDR2+1
SBC ADDR1+1
TAY
TXA
CMP :MVELEN
TYA
SBC :MVELEN+1
BCS :DOLEFT
JSR :MVERHT
JMP :EXIT
:DOLEFT
JSR :MVELEFT
:EXIT
JMP :MREXIT
:MVELEFT
LDY #0
LDX :MVELEN+1
BEQ :MLPART
:MLPAGE
LDA (ADDR1),Y
STA (ADDR2),Y ;MOVE ONE BYTE
INY
BNE :MLPAGE
INC ADDR1+1
INC ADDR2+1
DEX
BNE :MLPAGE
:MLPART
LDX :MVELEN
BEQ :MLEXIT
:MLLAST
LDA (ADDR1),Y
STA (ADDR2),Y
INY
DEX
BNE :MLLAST
:MLEXIT
JMP :MREXIT
:MVERHT
LDA :MVELEN+1
CLC
ADC ADDR1+1
STA ADDR1+1 ;POINT TO LAST P OF SRC
LDA :MVELEN+1
CLC
ADC ADDR2+1
STA ADDR2+1
LDY :MVELEN ;GET LENGTH OF LAST PAGE
BEQ :MRPAGE
:MR0
DEY
LDA (ADDR1),Y
STA (ADDR2),Y
CPY #0
BNE :MR0
:MRPAGE
LDX :MVELEN+1
BEQ :MREXIT
:MR1
DEC ADDR1+1
DEC ADDR2+1
:MR2
DEY
LDA (ADDR1),Y
STA (ADDR2),Y
CPY #0
BNE :MR2
DEX
BNE :MR1
:MREXIT
LDA RETADR+1
PHA
LDA RETADR
PHA
RTS
:MVELEN DS 2