; TURGEN SYSTEM
; Plugin: Standard
; Move routine - Move block of data to upper addresses
; ATASM
; From www.6502.org 

         *=1024
         
         BUFRLO=50
         BUFRHI=51
         BFENLO=52
         BFENHI=53

SIZEL    .BYTE 0      ; TS fills these fields
SIZEH    .BYTE 0

PREPARE  LDA #0       ; TS modifies opcodes, 
         STA BUFRLO   ; Addresses are END addresses increased by 1
         LDA #0
         STA BUFRHI
         LDA #0
         STA BFENLO
         LDA #0
         STA BFENHI         

MOVEUP   LDY #$FF
         LDX SIZEH
         BEQ MU3
MU1      DEC BUFRLO+1
         DEC BFENLO+1
MU2      LDA (BUFRLO),Y ; move a page at a time
         STA (BFENLO),Y
         DEY
         BNE MU2
         LDA (BUFRLO),Y ; handle Y = 0 separately
         STA (BFENLO),Y
         DEY
         DEX
         BNE MU1
MU3      LDX SIZEL
         BEQ MU5
         DEC BUFRLO+1
         DEC BFENLO+1
MU4      LDA (BUFRLO),Y ; move the remaining bytes
         STA (BFENLO),Y
         DEY
         DEX
         BNE MU4
MU5      JMP (736)