Question about writing to 1541

From: Spiro Trikaliotis (ml-cbmhackers_at_trikaliotis.net)
Date: 2005-04-21 20:18:19

Hello,

I have a question about writing to the 1541 (and 1571) drives, and I
hope you will be able to help me.

Looking at the "write to disk" DC routine ($F56E), you see the following
code:

.8:f5bf   B1 30      LDA ($30),Y  ; write the last bytes
.8:f5c1   50 FE      BVC $F5C1
.8:f5c3   B8         CLV
.8:f5c4   8D 01 1C   STA $1C01
.8:f5c7   C8         INY
.8:f5c8   D0 F5      BNE $F5BF
.8:f5ca   50 FE      BVC $F5CA    ; make sure the last byte is written

.8:f5cc   AD 0C 1C   LDA $1C0C    ; set read mode again
.8:f5cf   09 E0      ORA #$E0
.8:f5d1   8D 0C 1C   STA $1C0C
.8:f5d4   A9 00      LDA #$00     ; data port as input
.8:f5d6   8D 03 1C   STA $1C03

Ok, this works fine - as we all know, we can write to a disk with that
routine.

Now, the format routine handles the same (writing a block to disk) a
little bit differently:

.8:fd1e   50 FE      BVC $FD1E    ; make sure the last byte is written
.8:fd20   B8         CLV
.8:fd21   50 FE      BVC $FD21    ; write another (!) byte to disk
.8:fd23   B8         CLV
.8:fd24   20 00 FE   JSR $FE00    ; set read mode and data port as input

.8:fe00   AD 0C 1C   LDA $1C0C
.8:fe03   09 E0      ORA #$E0
.8:fe05   8D 0C 1C   STA $1C0C
.8:fe08   A9 00      LDA #$00
.8:fe0a   8D 03 1C   STA $1C03
.8:fe0d   60         RTS


Does anyone know why the routine waits an additional byte to be written?

I was correcting the cbmformat routine of cbm4win as I found out
something strange. My own format routine only had one "BVC *" inside of
it before setting the DC to read mode again. Reading the disk worked
perfectly, but somehow, my verify (doing a byte-by-byte compare) always
failed.

By comparing my format routine with the routine of the ROM, I
encountered the double "BVC *". Adding another one, the formatting works
as expected.

Unfortunately, I do not understand this. Can anyone explain me why I
need two "BVC *" in the formatting case, but only one in the writing
case?

Regards,
   Spiro.

-- 
Spiro R. Trikaliotis
http://www.trikaliotis.net/

       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail pre-2.1.8.