7.4

PROGRAMING AUXILIARY MEMORY

AUXMOVE AND XFER

No built—in assembly language subroutines may be used to transfer data and program control between main memory and auxiliary memory. These are AUXMOVE (starting location $C311) and XFER ($C314).

AUXMOVE is used to move blocks of data between main and auxiliary memory. Three pairs of bytes are used to pass addresses to AUXMOVE. Al is used for the starting address of the source block (AlL at $3C for low—order byte; A1H at $3D for high byte); A2 for source ending address (A2L at $3E for low byte; A2H at $3F for high byte): and A4 for the destination starting address (A4L at $42 for low byte; A4H at $43 for high byte).

Data addresses must be put into byte pairs in Page 0, and the carry bit set to select a move from Main to Auxiliary (SEC) or Auxiliary to Main memory (CLC). This must be done before calling the AUXMOVE routine. AUXMOVE cannot be used to copy data in the memory space switched by ALTZP (Page 0, stack, bank—switched memory).

When AUXMOVE is called by a JSR, the block of data specified by the A registers is copied in the direction specified by the carry bit. When complete, the x and y registers and accumulator are back as they were when the subroutine was called.

XFER is used to transfer program control between programs in main and auxiliary memory. To use the subroutine XFER to transfer control to and from segments in auxiliary memory, you must first set up three parameters: 1) the address of the routine being transferred to; 2) the direction—Main to Auxiliary memory, or vice versa; and 3) which Page 0 and stack to use.

The low byte of the program starting address is placed at $3ED, the high byte at $3EE (low byte first). The carry bit is set (SEC) to transfer from main to auxiliary, or cleared (CLC) to go from auxiliary to main memory. Set the overflow bit to use Page 0 and stack in auxiliary memory, or clear (CLV) the overflow bit to use Page 0 and stack in main memory.

Be sure to save the current stack pointer in current memory space before using XFER and restore it afterwards.

Control is passed to the XFER routine by a jump instruction rather than a subroutine call. The accumulator and transfer address are saved on the current stack, the soft switches set for the parameters selected, and the jump to the new program is executed.