Working with Files

BASIC Commands
LOADRetrieve a file from a device.
SAVEStore a file to a device.
VERIFYVerify that a file is written properly.
OPENOpen a communications channel.
CLOSEClose a communications channel.
CMDRedirect standard output to a channel.
GET#Get a byte of data from a channel.
INPUT#Get bytes from a channel.
PRINT#Write bytes to a channel.
KERNAL Routines
SETNAMSet name of a file or channel.
SETLFSDevice selection and options.
LOADRetrieve or verify a file from a device.
SAVEStore a file to a device.
OPENOpen a channel.
CLOSEClose a channel.
CLALLClose all channels.
CHKINSet a channel to input mode.
CHKOUTSet a channel to output mode.
CHRINGet a byte from a channel.
CHROUTWrite a byte to a channel.
READSTRead I/O status.
File Types
SEQ Sequential data
PRG Program file


LOAD

PreparationSETLFS, SETNAM
Send.A0 for LOAD, 1 for VERIFY
.XLow byte of loading address (if opened w/relocation)
.YHigh byte of loading address (if opened w/relocation)
Stack usage0
Address$FFD5, 65493
Returns.Aundefined
.XLow byte of ending address
.YHigh byte of ending address


SAVE

PreparationSETLFS, SETNAM
Send.AZero-page location of Starting Address pointer
.XLow byte of Ending Address
.YHigh byte of Ending Address
Stack usage0
Address$FFD8, 65496
Returns.Aundefined
.Xundefined
.Yundefined


OPEN

PreparationSETLFS, SETNAM
Send.Aignored
.Xignored
.Yignored
Stack usage0
Address$FFC0, 65472
Returns.Aundefined
.Xundefined
.Yundefined


SETNAM

Preparationnone
Send.ALength of filename
.XLow byte of address of filename
.YHigh byte of address of filename
Stack usage2
Address$FFBD, 65469
Returns.Apreserved
.Xpreserved
.Ypreserved


SETLFS

Preparationnone
Send.AFile number
.XDevice unit number
.YSecondary address or Command ($FF for no value)
Stack usage2
Address$FFBA, 65466
Returns.Apreserved
.Xpreserved
.Ypreserved


CLOSE

PreparationOPEN

Send.AFile number
.Xignored
.Yignored
Stack usage2
Address$FFC3, 65475
Returns.Aundefined
.Xundefined
.Yundefined


CLALL

Preparation[OPEN]
Send.Aignored
.Xignored
.Yignored
Stack usage11
Address$FFE7, 65511
Returns.Aundefined
.Xundefined
.Ypreserved


CHKIN

PreparationOPEN

Send.Aignored
.XFile number
.Yignored
Stack usage0
Address$FFC6, 65478
Returns.Aundefined
.Xundefined
.Yreserved


CHKOUT

PreparationOPEN
Send.Aignored
.XFile number
.Yignored
Stack usage4+
Address$FFC9, 65481
Returns.Aundefined
.Xundefined
.Ypreserved


CHRIN

Preparation[OPEN, CHKIN]
Send.Aignored
.Xignored
.Yignored
Stack usage7+
Address$FFCF, 65487
Returns.ARetrieved byte
.Xundefined
.Ypreserved


CHROUT

Preparation[OPEN, CHKOUT]
Send.AByte to send
.Xignored
.Yignored
Stack usage8+
Address$FFD2, 65490
Returns.Aundefined
.Xpreserved
.Ypreserved


READST

Preparationnone
Send.Aignored
.Xignored
.Yignored
Stack usage2
Address$FFB7, 65463
Returns.AStatus code
.Xpreserved
.Ypreserved


SEQ File Format

A sequential file is simply a list of bytes. When a SEQ file is opened for reading, the bytes from beginning to end will be consecutively loaded into the computer with each GET# or INPUT# command. When it is opened for writing, the PRINT# command will tack its output bytes after each other sequentially in the file.


PRG File Format

These files work exactly the same as sequential files, but the operating system looks at PRG files a little differently. The first two bytes in the file give the address to load the program to, and the remaining bytes are the program data to be loaded at that address. If the LOAD command is used with the ,1 option, this address is used to locate the loading point in memory. If it is omitted, the computer will load the file at the start of BASIC memory, usually $0801 (2049). The advantage of using PRG files over plain SEQ is that you can store the data as well as the address to be loaded to into the file, and ask the operating system to take care of the loading and storing into right place in memory.

You can treat SEQ files as PRG files by adding ,S to the end of the filename. For example, SAVE"PRG1,S",8 will save a SEQ file which is laid out like a PRG file: with the address at the beginning of the program. Likewise, LOAD"PRG1,S",8,1 will load the saved data back into its place in memory. Take care not to load SEQ files that do not have an address header, or the data will load in an unexpected location, probably crashing your computer.


All pages were generated with a text editor.
All images (except counter art and host ads) are generated, owned and (c) by me.

Home - Files - Super Reference
1