Commodore 64 Kernal (sic) reference

Kernal ROM (Yes, folks, Commodore did spell it "kernal", not "kernel" as God intended) contains some highly useful routines for interfacing with the outside world.

Sources:
ftp://ftp.funet.fi/pub/cbm/c64/programming/documents/c64-kernal.txt
Bruce Bailey: Commodore 64 exposed, Melbourne House, 1983, ISBN 0861611330

The file in funet had all of this information in a too-wide-to-read format so I reformatted it, and the book had the stack use information for some routines.

Truth to tell, I doubt those stack usage numbers - or maybe the Commodore programmers did a Really Good Job =)

CINT

Description  : Initialize VIC & screen editor
Jump addr    : FF81
Vector addr  :
Real code    : FF5B
I/O param    : 
Reg usage
       Entry : 
          Use: A,X,Y
      Return : 

IOINIT

Description  : Initialize CIA & IRQ
Jump addr    : FF84
Vector addr  : 
Real code    : FDA3
I/O param    : 
Reg usage
       Entry : 
          Use: A,X,Y
      Return : 

RAMTAS

Description  : RAM test & search RAM end
Jump addr    : FF87
Vector addr  : 
Real code    : FD50
I/O param    : 
Reg usage
       Entry : 
          Use: A,X,Y
      Return : 

RESTOR

Description  : restore default I/O vectors
Jump addr    : FF8A
Vector addr  : 
Real code    : FD15
Stack use    : 2
I/O param    : 
Reg usage
       Entry : 
          Use: A,Y
      Return : 

VECTOR

Description  : read/set I/O vectors
Jump addr    : FF8D
Vector addr  : 
Real code    : FD1A
Stack use    : 2
I/O param    : in: C=0 moves from Y/X to vectors
                   C=1 moves vectors to Y/X
Reg usage
       Entry : X,Y
          Use: A,Y
      Return : X

SETMSG

Description  : enable/disable KERNAL messages
Jump addr    : FF90
Vector addr  : 
Real code    : FE18
I/O param    : in: A bit7=1 error msgs on
                     bit6=1 control msgs on
Reg usage
       Entry : A
          Use: A
      Return : 

SECOND

Description  : send secondary addr after listen
Jump addr    : FF93
Vector addr  : 
Real code    : EDB9
Stack use    : 0
I/O param    : in: A=secondary address
Reg usage
       Entry : A
          Use: A
      Return : 

TKSA

Description  : send secondary addr after talk
Jump addr    : FF96
Vector addr  : 
Real code    : EDC7
Stack use    : 0
I/O param    : in: A=secondary address
Reg usage
       Entry : A
          Use: A
      Return : 

MEMTOP

Description  : read/set top of memory
Jump addr    : FF99
Vector addr  : 
Real code    : FE25
Stack use    : 2
I/O param    : in: C=0; Y/X addresses
  Reg usage
       Entry : X,Y
          Use: 
      Return : X,Y
I/O param    : out: C=1; Y/X addresses
  Reg usage
       Entry : 
          Use: X,Y
      Return : X,Y

MEMBOT

Description  : read/set bottom of memory
Jump addr    : FF9C
Vector addr  : 
Real code    : FE34
Stack use    : 0
I/O param    : in: C=0; Y/X addresses
  Reg usage
       Entry : X,Y
          Use: 
      Return : X,Y
I/O param    : out: C=1; Y/X addresses
  Reg usage
       Entry : 
          Use: X,Y
      Return : X,Y

SCNKEY

Description  : Scan keyboard
Jump addr    : FF9F
Vector addr  : 
Real code    : EA87
Stack use    : 0
I/O param    : 
Reg usage
       Entry : 
          Use: A,X,Y
      Return : 

SETTMO

Description  : Set IEEE timeout
Jump addr    : FFA2
Vector addr  : 
Real code    : FE21
I/O param    : in: A bit7=1 disable, bit7=0 enable
Reg usage
       Entry : A
          Use: 
      Return : A

ACPTR

Description  : input byte from SERIAL
Jump addr    : FFA5
Vector addr  : 
Real code    : EE13
Stack use    : 13
I/O param    : out:A=byte, C=1 and ST=2 if timeout
Reg usage
       Entry : 
          Use: A
      Return : A

CIOUT

Description  : Output byte to SERIAL
Jump addr    : FFA8
Vector addr  : 
Real code    : EDDD
Stack use    : 0
I/O param    : in: A=byte, C=1 and ST=3 if timeout
Reg usage
       Entry : A
          Use: 
      Return : A

UNTLK

Description  : Untalk all SERIAL devices
Jump addr    : FFAB
Vector addr  : 
Real code    : EDEF
Stack use    : 0
I/O param    : 
Reg usage
       Entry : 
          Use: A
      Return : 

UNLSN

Description  : Unlisten all SERIAL devices
Jump addr    : FFAE
Vector addr  : 
Real code    : EDFE
Stack use    : 0
I/O param    : 
Reg usage
       Entry : 
          Use: A
      Return : 

LISTEN

Description  : Make SERIAL device listen
Jump addr    : FFB1
Vector addr  : 
Real code    : ED0C
Stack use    : 0
I/O param    : in: A=device number
Reg usage
       Entry : A
          Use: A
      Return : 

TALK

Description  : Make SERIAL device talk
Jump addr    : FFB4
Vector addr  : 
Real code    : ED09
Stack use    : 0
I/O param    : in: A=device number
Reg usage
       Entry : A
          Use: A
      Return : 

READST

Description  : Read I/O status byte
Jump addr    : FFB7
Vector addr  : 
Real code    : FE07
Stack use    : 2
I/O param    : out: A=status byte
Reg usage
       Entry : 
          Use: A
      Return : A

SETLFS

Description  : Set file parameters
Jump addr    : FFBA
Vector addr  : 
Real code    : FE00
Stack use    : 2
I/O param    : in: A=logical file number
                   X=device number
                   Y=secondary addr
Reg usage
       Entry : A,X,Y
          Use: 
      Return : A,X,Y

SETNAM

Description  : Set file name
Jump addr    : FFBD
Vector addr  : 
Real code    : FDF9
Stack use    : 0
I/O param    : in: A=length of filename
                   Y/X=pointer to name addr
Reg usage
       Entry : A,X,Y
          Use: 
      Return : A,X,Y

OPEN

Description  : Open logical file
Jump addr    : FFC0
Vector addr  : 031A
Real code    : F34A
Stack use    : 0
I/O param    : out: A=error# if C=1
Reg usage
       Entry : 
          Use: A,X,Y
      Return : 
Comment      : First call SETLFS and SETNAM with appropriate
               parameters.

CLOSE

Description  : Close a logical file
Jump addr    : FFC3
Vector addr  : 031C
Real code    : F291
Stack use    : 0
I/O param    : in: A=logical file number
Reg usage
       Entry : A
          Use: A,X,Y
      Return : 

CHKIN

Description  : Open channel for input
Jump addr    : FFC6
Vector addr  : 031E
Real code    : F20E
Stack use    : 0
I/O param    : in: X=logical file number
Reg usage
       Entry : X
          Use: 
      Return : A,X

CHKOUT

Description  : Open channel for output
Jump addr    : FFC9
Vector addr  : 0320
Real code    : F250
Stack use    : 0
I/O param    : in: X=logical file number
Reg usage
       Entry : X
          Use: 
      Return : A,X

CLRCHN

Description  : Restore default devices
Jump addr    : FFCC
Vector addr  : 0322
Real code    : F333
Stack use    : 9
I/O param    : 
Reg usage
       Entry : 
          Use: A,X
      Return : 

CHRIN

Description  : Input character
Jump addr    : FFCF
Vector addr  : 0324
Real code    : F147
Stack use    : 0
I/O param    : out:A=character, C=1 and ST=error
Reg usage
       Entry : 
          Use: A
      Return : A

CHROUT

Description  : Output character
Jump addr    : FFD2
Vector addr  : 0326
Real code    : F1CA
Stack use    : 0
I/O param    : in: A=character, C=1 and ST=error
Reg usage
       Entry : A
          Use: 
      Return : A

LOAD

Description  : Load after call SETLFS, SETNAM
Jump addr    : FFD5
Vector addr  : 0330
Real code    : F49E
Stack use    : 0
I/O param    : in: A=0 load, a=1 verify
                   Y/X = dest.addr if sec.addr=0
Reg usage
       Entry : A,X,Y
          Use: A,X,Y
      Return : A,X,Y

SAVE

Description  : Save.
Jump addr    : FFD8
Vector addr  : 0332
Real code    : F5DD
Stack use    : 0
I/O param    : in: A=zero page pointer to start.addr
                   Y/X=ending address
Reg usage
       Entry : A,X,Y
          Use: A,X,Y
      Return : 
Comments     : First call SETLFS and SETNAM with appropriate
               parameters

SETTIM

Description  : Set jiffy clock
Jump addr    : FFDB
Vector addr  : 
Real code    : F6E4
Stack use    : 2
I/O param    : in: A=MSB, X=middle, Y=LSB
Reg usage
       Entry : A,X,Y
          Use: 
      Return : 

RDTIM

Description  : Read jiffy clock
Jump addr    : FFDE
Vector addr  : 
Real code    : F6DD
Stack use    : 2
I/O param    : out:A=MSB, X=middle, Y=LSB
Reg usage
       Entry : 
          Use: A,X,Y
      Return : A,X,Y

STOP

Description  : Check stop key
Jump addr    : FFE1
Vector addr  : 0328
Real code    : F6ED
Stack use    : 0
I/O param    : out: Z=0 if STOP not used, X unchanged
                    Z=1 if STOP used, X changed
                    A=last line of keyboard matrix
Reg usage
       Entry : 
          Use: A
      Return : A (X if STOP used)

GETIN

Description  : Get a byte from channel
Jump addr    : FFE4
Vector addr  : 032A
Real code    : F13E
Stack use    : 0
I/O param    : out:keyboard:A=0 if buffer empty
  Reg usage
       Entry : 
          Use: A,X,Y
      Return : A
I/O param    : out:RS232:status byte
  Reg usage
       Entry : 
          Use: A
      Return : A
I/O param    : out:serial:status byte
  Reg usage
       Entry : 
          Use: A
      Return : A
I/O param    : out:tape:status byte
  Reg usage
       Entry : 
          Use: A,Y
      Return : A

CLALL

Description  : Close or abort all files
Jump addr    : FFE7
Vector addr  : 032C
Real code    : F32F
Stack use    : 11
I/O param    : 
Reg usage
       Entry : 
          Use: A,X
      Return : 

UDTIM

Description  : Update jiffy clock
Jump addr    : FFEA
Vector addr  : 
Real code    : F69B
I/O param    : 
Reg usage
       Entry : 
          Use: 
      Return : A,X
Comment      : To update the yiffy clock, JSR $6969. =)

SCREEN

Description  : Return screen size
Jump addr    : FFED
Vector addr  : 
Real code    : E505
Stack use    : 2
I/O param    : out:X=columns, Y=rows
Reg usage
       Entry : 
          Use: X,Y
      Return : X,Y
Comment      : I wonder if there's any actual use for this call???

PLOT

Description  : Read/set cursor position
Jump addr    : FFF0
Vector addr  : 
Real code    : E50A
Stack use    : 2
I/O param    : in: C=0, X=row, Y=column
  Reg usage
       Entry : X,Y
          Use: 
      Return : X,Y
I/O param    : out:C=1, X=row, Y=column
  Reg usage
       Entry : 
          Use: X,Y
      Return : X,Y

IOBASE

Description  : Returns the addr of I/O devices
Jump addr    : FFF3
Vector addr  : 
Real code    : E500
Stack use    : 2 (?)
I/O param    : out:Y/X=addr($DC00)
Reg usage
       Entry : 
          Use: X,Y
      Return : X,Y

Log in or registerto write something here or to contact authors.