Subj : Re: Closing a file in Assembly on the VIC-20
To   : Tilmann Hentze
From : Silver Dream !
Date : Wed Jun 30 2021 10:49 am

On 17.06.2021 13:29, Tilmann Hentze wrote:

>> main
>>              lda  #$07         ; Length of file name
>>              ldx  #<filename   ; Low byte of file name location
>>              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.

Shouldn't make any difference. The order of the two preparatory calls is
interchangeable.

>>              lda  #<flash      ; Low byte of start of memory block to save
>>              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.

I am not sure what are you trying to say here. This takes LO/HI bytes of
an address. Assembler takes care of both being correct.

>
>>              jsr  SAVE            ; Perform save
>
>>              lda  #$08         ; Logical file number
>>              jsr  CLOSE        ; Close the file

One needs to CLOSE() (or CLALL() in some cases) files that were
previously OPEN(). Not needed for SAVE().

> Looks good to me.

LGTM too.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)