Purpose: Save to file
Call address: $FFD8 (hex) 65496 (decimal)
Preparation:
Registers: .A = pointer to start adr .X = end adr lo .Y = end adr hi Memory: system map Flags: none Calls: SETLFS, SETNAM, SETBNKResults:
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 endThere 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.
EXAMPLE: SAVE "program",8
LDA #length ;fnlen LDX #<filename ;fnadr LDY #>filename JSR $FFBD ;SETNAM LDA #0 ;save from bank (RAM0) LDX #0 ;fnbank (RAM0) JSR $FF68 ;SETBNK LDA #0 ;la (not used) LDX #8 ;fa LDY #0 ;sa (cassette only) JSR $FFBA ;SETLFS LDA #start ;pointer to start address LDX end ;ending address lo LDY end+1 ;ending adr hi JSR $FFD8 ;SAVE BCS error filename .BYTE "program length = 7 start .WORD address1 ;page-0 end .WORD address2