Assembly Language And The 1541 - Commodore 1541 User Manual

Disk drive
Hide thumbs Also See for 1541:
Table of Contents

Advertisement

10.
ASSEMBLY LANGUAGE AND THE 1541
If you want to use your 1541 disk drive to manipulate data directly from assembly
language you can use the information presented below.
Here is a list of subroutines that provide the start of memory locations in each of
the Kernal routines. These routines are used in conjunction with the assembly language
command JSR to jump to that subroutine location in memory:
SUBROUTINE
SETLFS
= $FFBA
SETNAM = $FFBD
OPEN
= $FFC0
CLOSE
= $FFC3
CHKIN
= $FFC6
CLRCH
= $FFCC
BASIN
= SFFCF
BSOUT
= $FFD2
set logical, physical & secondary addresses
save length & address of filename
open a logical file
close a logical file
open a channel for input
clear all channels
get a byte from a file
output a character to the screen
For a more complete description as to what each routine does and what
parameters are passed to and from each routine, see your Commodore 64 or VIC-20
Programmer's Reference Guide.
Now, for a practical application of the subroutines listed above, here is a sample
program using those routines to read a sequential file on a disk. Assume that you have
stored the filename "TEST" at $C000.
INIT
LDA#$04
LDX#$00
LDY#$C0
JSR SETNAM
LDA#$03
LDX#$08
LDY#$00
JSR SETLFS
JSR OPEN
LDX #$03
JSR CHKIN
your program info
JSR BASIN
BEQ END
JSR BSOUT
JMP your prog, info
END
LDA#$03
JSR CLOSE
JSR CLRCH
RTS
initialize:
filename length
low byte of filename address
high byte of filename address
save length & address of filename
logical address
device number
secondary address (0 = read seq. file)
set logical, physical & secondary addresses
open logical file
set x-register to logical address
open input channel
get data and print it one byte at a time
get one byte
if 0 then end of file or error
output character to the screen
loop
set accumulator to logical address
close file
clear channels and reset defaults
end of assembly language program
50

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents