Re: Am I wrong or.... not ???

From: Spiro Trikaliotis <ml-cbmhackers_at_trikaliotis.net>
Date: Mon, 13 Jul 2026 23:11:05 +0200
Message-ID: <alVUaWw_1aBYAVo2_at_hermes.local.trikaliotis.net>
Hello Ruud,

* On Mon, Jul 13, 2026 at 10:20:13PM +0200 ruud_at_baltissen.org wrote:
> 
> I ran into something that puzzles me. AFAIK everything should be OK because
> nobody complained but I cannot find out where I'm wrong then. Please have a
> look at the disassembly of 'Open a logical file' that starts at $F34A. The
> interesting part starts at
> 
> A_F359:					;				[F359]
> 	ldx	IndFileTable		; get the open file count	[98]

Here, X contains the "index" into the buffer *before* the increment!

> 	cpx	#10			; < maximum + 1 ?
> 	bcc	A_F362			; if less than maximum + 1 go open file

If X < 10, then branch to A_F362. Thus, if we reach at A_F362, we are
sure that X < 10 (and X >= 0, because the comparison is unsigned).

> 	jmp	TooManyFilesErr		; else do 'too many files error' and
> 					; return			[F6FB]
> A_F362:					;				[F362]
> 	inc	IndFileTable		; increment the open file count

Here, IndFileTable is incremented, that's right. But note that X is not
changed! So it still contains the value *before* the increment. Thus, X is
known to be less than 10.

> 	lda	LogicalFileNum		; get the logical file
> 	sta	LogicalFileTbl,X	; save it to the logical file table
> 					;				[0259]

So, it is saved in the index area 0..9, which is correct.

> Am I wrong ???

Yes. :)

> Something else: I used the Dutch version of Databecker's 'C64 intern' to
> check the addresses. I also have the German version but I would like to have
> an English version of the ROM listing. Any pointers, please? TIA!

Books from Data Becker where released by Abacus Software in the U.S.:
https://archive.org/details/The_Anatomy_of_the_Commodore_64
 

Regards,
Spiro

-- 
https://spiro.trikaliotis.net/
Received on 2026-07-13 23:00:02

Archive generated by hypermail 2.4.0.