Index

Function Name: LOAD

Purpose: Load from file
Call address: $FFD5 (hex) 65493 (decimal)

Description: This routine LOADs data from an input device into C128 memory. It can also be used to VERIFY that data in memory matches that in a file. LOAD performs device-specific tasks for serial and cassette LOADs. You cannot LOAD from RS-232 devices, the screen or the keyboard. While LOAD performs all the tasks of an OPEN, it does not create any logical files as an OPEN does. Also note that LOAD cannot "wrap" memory banks. As with any FO, the I/O status is updated appropriately and can be read via READSS. LOAD has two options that the user must select:

  1. LOAD vs. VERIFY: The contents of .A passed at the call to LOAD deter- mines which mode is in effect. If .A is zero, a LOAD operation will be performed and memory will be overwritten. If .A is nonzero, a VERIFY operation will be performed and the result passed via the error mechanism.
  2. LOAD ADDRESS: the secondary address (SA) setup by the call to SETLFS determines where the LOAD starting address comes from. If the SA is zero, the user wants the address in .X and .Y at the time of the call to be used. If the SA is nonzero, the LOAD starting address is read from the file header itself and the file is loaded into the same place from which it was SAVEd.
The C128 serial LOAD routine automatically attempts to BURST load a file, and resorts to the normal load mechanism (but still using the FAST serial routines) if the BURST handshake is not returned.
The path to LOAD is through an indirect RAM vector at $330. Applications may therefore provide their own LOAD procedures or supplement the system procedures by redirecting this vector to their own routine.

EXAMPLE:

	LDA	#length		;fnlen
	LDX	#filename
	JSR	$FFBD		;SETNAM

	LDA	#0		;load/verify bank (RAM0)
	LDX	#0		;fnbank (RAM0)
	JSR	$FF68		;SETBNK

	LDA	#0		;la (not used)
	LDX	#8		;fa
	LDY	#$FF		;sa (SA>0 normal load)
	JSR	$FFBA		;SETLFS

	LDA	#0		;load, not verify
	LDX	#<load adr	;(used only if SA = 0)
	LDY	#>load adr	;(used only if SA = 0)
	JSR	$FFD5		;LOAD
	BCS	error
	STX	end_lo
	STY	end_hi

filename .BYTE "program
length   = 7