The task involves screen/keyboard I/O, files, disk, printer, tape, RS-232, serial bus, LOAD, SAVE, OPEN, CLOSE, GETIN, CHROUT, or KERNAL calls from assembly.
Prefer KERNAL jump-table calls at the top of memory. They are stable public entry points and safer than jumping into undocumented ROM internals.
| Address | Name | Purpose |
|---|---|---|
$FF81 |
CINT |
Initialize screen editor |
$FF84 |
IOINIT |
Initialize I/O devices |
$FF87 |
RAMTAS |
Initialize RAM/test memory |
$FF8A |
RESTOR |
Restore default vectors |
$FF8D |
VECTOR |
Read/set RAM vectors |
$FF90 |
SETMSG |
Control system messages |
$FF93 |
SECOND |
Send secondary address after LISTEN |
$FF96 |
TKSA |
Send secondary address after TALK |
$FF99 |
MEMTOP |
Read/set top of memory |
$FF9C |
MEMBOT |
Read/set bottom of memory |
$FF9F |
SCNKEY |
Scan keyboard |
$FFA2 |
SETTMO |
Set serial timeout |
$FFA5 |
ACPTR |
Input byte from serial bus |
$FFA8 |
CIOUT |
Output byte to serial bus |
$FFAB |
UNTLK |
Send UNTALK |
$FFAE |
UNLSN |
Send UNLISTEN |
$FFB1 |
LISTEN |
Command device to listen |
$FFB4 |
TALK |
Command device to talk |
$FFB7 |
READST |
Read I/O status byte |
$FFBA |
SETLFS |
Set logical file, device, secondary address |
$FFBD |
SETNAM |
Set filename pointer and length |
$FFC0 |
OPEN |
Open logical file |
$FFC3 |
CLOSE |
Close logical file |
$FFC6 |
CHKIN |
Set input channel |
$FFC9 |
CHKOUT |
Set output channel |
$FFCC |
CLRCHN |
Restore default I/O channels |
$FFCF |
CHRIN |
Input character |
$FFD2 |
CHROUT |
Output character |
$FFD5 |
LOAD |
Load RAM from device |
$FFD8 |
SAVE |
Save RAM to device |
$FFDB |
SETTIM |
Set system clock |
$FFDE |
RDTIM |
Read system clock |
$FFE1 |
STOP |
Test STOP key |
$FFE4 |
GETIN |
Get character from keyboard/input buffer |
$FFE7 |
CLALL |
Close all channels/files |
$FFEA |
UDTIM |
Update software clock |
$FFED |
SCREEN |
Get screen size |
$FFF0 |
PLOT |
Read/set cursor position |
$FFF3 |
IOBASE |
Return I/O base address |
lda #'A' ; assembler may translate ASCII differently; PETSCII 65 works for A
jsr $ffd2 ; CHROUT
rts
wait: jsr $ffe4 ; GETIN
beq wait ; zero means no key available
jsr $ffd2 ; echo key
rts
Typical sequence:
SETLFS with logical file, device number, secondary address.SETNAM with filename length and pointer.OPEN.CHKIN or CHKOUT.CHRIN / CHROUT.CLRCHN.CLOSE.| Device | Meaning |
|---|---|
| 0 | Keyboard |
| 1 | Cassette |
| 2 | RS-232 |
| 3 | Screen |
| 4-5 | Printers, usually serial bus |
| 8-11 | Disk drives, commonly 8 for first 1541 |
When writing KERNAL-call assembly:
CLRCHN after redirected I/O.Powered by TurnKey Linux.