Re: Cursory analyses of CBM readdir bug (was: [cc65] Re: readdir bug)

From: <silverdr1wfmh.org.pl>
Date: 2013-01-10 11:59:18
On 2013-01-10, at 00:50, Greg King wrote:

>> Well-written programs may as well check for the C flag on return;
>> which is a sort of convention with many KERNAL routines.
>> Unfortunately, somebody "forgot" to add this to, e. g., OPEN call.
> 
> Are you talking about the Kernal's function or BASIC's OPEN statement? (The Kernal's OPEN does set the Carry flag; and, BASIC does check it.)

What about this simple test then:
*******************************
	lda #$08
	tax
	tay
	jsr $ffba	; SETLFS
	lda #fnamelength
	ldx #<fname
	ldy #>fname
	jsr $ffbd	; SETNAM
	jsr $ffc0	; OPEN
	bcc white
	lda #$02
setborder:
	sta $d020
	bne end
white:
	lda #$01
	bne setborder
end:
	lda #$08
	jsr $ffc3	; CLOSE
	rts

fname:
	.byte	"test"
fnamend:
fnamelength = fnamend - fname
*******************************

This is the use case I am referring to and I get white, no matter whether the file opened correctly or not. It is honest question - I'd be glad not to use status channel in this case but I know no other way to confirm that the file opened correctly (or not).

>> [..]
>> Anyway -- this is quite OT here.
> 
> It actually isn't Off-Topic.  People who want to deal with many drives and
> many files, as you did -- but, in C -- will need to know that CC65's CBM
> library does what I described:  When the first file, on a particular mass
> storage unit, is openned, the library opens a status file, too.  It keeps
> that status file open until all files, on that unit, have been closed.  The
> library does that separately for each unit!  The ROM KERNAL has a limit of
> 10 open files; but, CC65's CBM library has a limit of 8!  And, that count can
> include stdin, stdout, and stderr.

This is indeed an important and non-OT information. I haven't checked the docs but I believe it should be documented too. What I said was OT, was the purely CBM "feature" that messes with data files whenever one closes status channel. As Spiro mentioned: opening status channel is a NOOP on the drive but closing it... uh-oh.. ;-)

-- 
SD!----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Jan 10 11:59:30 2013

This archive was generated by hypermail 2.1.8 : 2013-01-10 11:59:34 CET