Define I/O memory page
Function AddressDescription
IOBASE FFF3Define I/O memory page

This routine sets the X and Y registers to the address of the memory section where the memory mapped 110 devices are located. This address can then be used with an offset to access the memory mapped I/O devices in the Commodore 64. The offset is the number of locations from the beginning of the page on which the I/O register you want is located. The X register contains the low order address byte, while the Y register contains the high order address byte.

This routine exists to provide compatibility between the Commodore 64, VIC-20, and potential future models of the Commodore 64. If the I/O locations for a machine language program are set by a call to this routine, they should still remain compatible with future versions of the Commodore 64, the KERNAL and BASIC.

JSRIOBASESet the Data Direction Register (DDR) of user port
STXFREKZPStore base address
LDA#0New value of User Port DDR
LDY#2Offset to DDR of User Port
STA(FREKZP),YSet the register

Note: FREKZP (0x00FB) in this example is a 4 byte block of zeropage memory unused by Basic or Kernal and is available for user code.

For the C64 the value returned is 0xDC00 - address of CLA #1

For the C128 the value returned is 0xD000 - address of the VIC chip