Subj : Re: Closing a file in Assembly on the VIC-20 To : Lawrence Woodman From : Tilmann Hentze Date : Thu Jun 17 2021 11:29 am Lawrence Woodman wrote: > I have created a piece of code which replicates the problem below if > anyone has any ideas where I'm going wrong I'd be very grateful. > ; Basic Stub > TOK_SYS = $9E ; SYS token > .byt $01, $10 ; Load address ($1001) > * = $1001 > .word basicEnd ; Next Line link, here end of Basic program > .word 1 ; The line number for the SYS statement > .byt TOK_SYS ; SYS token > .asc " " > .asc "4110" ; Start of machine language > .byt 0 ; End of Basic line > basicEnd .word 0 ; End of Basic program > ; KERNEL/BASIC ROM Routines > CLOSE = $FFC3 > SAVE = $FFD8 > SETLFS = $FFBA > SETNAM = $FFBD > main > lda #$07 ; Length of file name > ldx # ldy #>filename ; High byte of file name location > jsr SETNAM ; Set the name > lda #$08 ; Logical file number > ldx #$08 ; Device number > ldy #$01 ; Secondary address - $01 because saving > jsr SETLFS ; Set above parameters I'd switch the two previous blocks around, so that you first set up the channel and then set the file name. > lda # sta $C1 > lda #>flash ; High byte of start of memory block to save > sta $C2 > lda #$C1 ; Pointer to location of start address > ldx #<(flashend+1) ; Low byte of (end of memory block + 1) > ldy #>(flashend+1) ; High byte of (end of memory block + 1) The high byte should probaly only increment, when the low byte is $ff. > jsr SAVE ; Perform save > lda #$08 ; Logical file number > jsr CLOSE ; Close the file Looks good to me. Perhaps it will work with the first mentioned change? Best regards, Tilmann. --- SoupGate-Win32 v1.05 * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3) .