[Addressed Listing] [Alphabetical Listing] [Error Codes]

IOBASE

     Purpose:  Define I/O memory page
Call address:  $FFF3 (hex) 65523 (decimal)
Communication registers:  X, Y
Preparatory routines:  None
Error returns:  None
Stack requirements:  2
Registers affected:  X, Y

Description:

This routine sets the X and Y registers to the address of the memory section where the memory mapped I/O 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 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.

How to Use:

  1. Call this routine by using the JSR instruction.
  2. Store the X and the Y registers in consecutive locations.
  3. Load the Y register with the offset.
  4. Access that I/O location.

EXAMPLE:

     ;SET THE DATA DIRECTION REGISTER OF THE USER PORT TO 0 (INPUT)
     JSR IOBASE
     STX POINT       ;SET BASE REGISTERS
     STY POINT+1
     LDY #2
     LDA #0          ;OFFSET FOR DDR OF THE USER PORT
     STA (POINT),Y   ;SET DDR TO 0

[Addressed Listing] [Alphabetical Listing] [Error Codes]