
 1000  *---------------------------------
 1010  *      GENERAL MOVE SUBROUTINE
 1020  *---------------------------------
 1030  *      BRUN THE PROGRAM TO SET UP AS CONTROL-Y
 1040  *      MONITOR ROUTINE
 1050  *---------------------------------
 1060  *      USE LIKE MONITOR MOVE SUBROUTINE:
 1070  *      A1L,A1H -- SOURCE START ADDRESS
 1080  *      A2L,A2H -- SOURCE END ADDRESS
 1090  *      A4L,A4H -- DESTINATION START ADDRESS
 1100  *---------------------------------
 1110  BLOCK.SIZE .EQ $00,01
 1120  A1L    .EQ $3C
 1130  A1H    .EQ $3D
 1140  A2L    .EQ $3E
 1150  A2H    .EQ $3F
 1160  A4L    .EQ $42
 1170  A4H    .EQ $43
 1180  CONTROL.Y  .EQ $3F8
 1190  *---------------------------------
 1200  CONTROL.Y.SETUP
 1210         LDA #$4C     JMP OPCODE
 1220         STA CONTROL.Y
 1230         LDA #GENERAL.MOVE
 1240         STA CONTROL.Y+1
 1250         LDA /GENERAL.MOVE
 1260         STA CONTROL.Y+2
 1270         RTS
 1280  *---------------------------------
 1290  GENERAL.MOVE
 1300         PHA          SAVE REGISTERS
 1310         TYA
 1320         PHA
 1330         TXA
 1340         PHA
 1350         INC A2L      BUMP END ADDRESS ONCE
 1360         BNE .1
 1370         INC A2H
 1380  .1     SEC          COMPUTE SIZE OF BLOCK
 1390         LDA A2L
 1400         SBC A1L
 1410         STA BLOCK.SIZE
 1420         LDA A2H
 1430         SBC A1H
 1440         STA BLOCK.SIZE+1
 1450         TAX
 1460         INX          NUMBER OF BLOCKS TO MOVE
 1470         LDA A1L      DETERMINE DIRECTION
 1480         CMP A4L
 1490         LDA A1H
 1500         SBC A4H
 1510         BCC .2       A1 < A4
 1520         JSR MOVE.DOWN
 1530         JMP .3
 1540  .2     JSR MOVE.UP
 1550  .3     PLA          RESTORE REGS
 1560         TAX
 1570         PLA
 1580         TAY
 1590         PLA
 1600         RTS
 1610  *---------------------------------
 1620  MOVE.DOWN
 1630         LDY #0
 1640         DEX          ANY WHOLE BLOCKS LEFT?
 1650         BEQ .2       NO
 1660  .1     LDA (A1L),Y  MOVE 256 BYTES
 1670         STA (A4L),Y
 1680         INY
 1690         BNE .1
 1700         INC A1H      POINT AT NEXT BLOCK
 1710         INC A4H
 1720         DEX          ANY MORE WHOLE BLOCKS?
 1730         BNE .1       YES
 1740  .2     LDX BLOCK.SIZE   ANY EXTRA BYTES IN A SHORT BLOCK?
 1750         BEQ .4       NONE LEFT
 1760  .3     LDA (A1L),Y
 1770         STA (A4L),Y
 1780         INY
 1790         DEX
 1800         BNE .3
 1810  .4     RTS
 1820  *---------------------------------
 1830  MOVE.UP
 1840         CLC          COMPUTE DESTINATION END + 1
 1850         LDA A4L
 1860         ADC BLOCK.SIZE
 1870         STA A4L
 1880         LDA A4H
 1890         ADC BLOCK.SIZE+1
 1900         STA A4H
 1910         LDY #0
 1920         BEQ .3       ...ALWAYS
 1930  *---MOVE A WHOLE BLOCK------------
 1940  .1     LDA (A2L),Y  MOVE BYTES 255 THRU 1 IN BLOCK
 1950         STA (A4L),Y
 1960  .2     DEY
 1970         BNE .1
 1980         LDA (A2L),Y  MOVE LOWEST BYTE IN BLOCK
 1990         STA (A4L),Y
 2000  .3     DEC A2H
 2010         DEC A4H
 2020         DEX          ANY MORE BLOCKS?
 2030         BNE .2       YES
 2040  *---MOVE SHORT BLOCK IF ANY-------
 2050         LDX BLOCK.SIZE
 2060         BEQ .5       NONE LEFT
 2070  .4     DEY
 2080         LDA (A2L),Y
 2090         STA (A4L),Y
 2100         DEX
 2110         BNE .4
 2120  .5     RTS

