Function Name: SAVE

Purpose: Save to file
Call address: $FFD8 (hex) 65496 (decimal)

	Registers:	.A = pointer to start adr
			.X = end adr lo
			.Y = end adr hi
	Memory:		system map
	Flags:		none
	Registers:	.A = error code (if any)
			.X = used
			.Y = used
	Memory:		STATUS updated
	Flags:		.C = 1 -> error

Description: This routine SAVEs data from C128 memory to an output device. SAVE per- forms device-specific tasks for serial and cassette SAVEs. You cannot SAVE from RS-232 devices, the screen or the keyboard. While SAVE performs all the tasks of an OPEN, it does not create any logical files as an OPEN does. The starting address of the area to be SAVEd must be placed in a zero-page vector and the address of this vector passed to SAVE in .A at the time of the call. The address of the last byte to be SAVEd PLUS ONE is passed in .X and .Y at the same time. Cassette SAVEs utilize the secondary address (SA) to specify the type of tape header(s) to be generated:

SA (bit 0) = 0 -> relocatable  (blf) file
           = 1 -> absolute     (plf) file
SA (bit 1) = 0 -> normal end
           = 1 -> write EOT header at end
There is no BURST save; the normal FAST serial routines are used. As with any I/O, the I/O status will be updated appropriately and can be read via READST.
The path to SAVE is through an indirect RAM vector at $332. Applications may therefore provide their own SAVE procedures or supplement the system's by redirecting this vector to their own routine.

EXAMPLE: SAVE "program",8

	LDA	#length		;fnlen
	LDX	#<filename	;fnadr
	LDY	#>filename

	LDA	#0		;save from bank (RAM0)
	LDX	#0		;fnbank (RAM0)

	LDA	#0		;la (not used)
	LDX	#8		;fa
	LDY	#0		;sa (cassette only)

	LDA	#start		;pointer to start address
	LDX	end		;ending address lo
	LDY	end+1		;ending adr hi
	BCS	error
filename .BYTE "program
length   = 7
start    .WORD address1		;page-0
end	 .WORD address2