Re: more serial woe

From: Spiro Trikaliotis (ml-cbmhackers_at_trikaliotis.net)
Date: 2004-08-25 12:26:56

Hello,

* On Wed, Aug 25, 2004 at 10:23:19AM +0100 Christopher Phillips wrote:

> On 27 Jul 2004, at 19:42, Groepaz wrote:
> (and I just received last night!)

You're lucky. I'm just receiving now. :-(

 
> Next question - when working the job queue, is there any point doing a 
> SEEK ($B0) before a READ ($80)?

Yes, there is a point in doing a seek before a read.

When the job IRQ loop looks for the type of the code, it gets first to
$F3B1, which is the seek routine. It gets there whenever the code is not
$D0 (= EXECUTE), because every other command needs a seek before it.

When it is executed, we come to the following code:


.8:f3ec   A5 45      LDA $45    ' get the job code (- $80)
.8:f3ee   C9 30      CMP #$30   ' is it seek? ($D0-$80)
.8:f3f0   F0 1E      BEQ $F410  ' yes, we're done

         ' Now, check the ID of the disc if it matches the stored ID
.8:f3f2   A5 3E      LDA $3E    ' get drive number (always 0 with 1541)
.8:f3f4   0A         ASL A      ' *2
.8:f3f5   A8         TAY        '
.8:f3f6   B9 12 00   LDA $0012,Y' this is the "expected" ID1 of the disc
.8:f3f9   C5 16      CMP $16    ' compare with the just read ID1 of the header
.8:f3fb   D0 1E      BNE $F41B  ' ID1 does not match, return error

.8:f3fd   B9 13 00   LDA $0013,Y' this is the "expected" ID2 of the disc
.8:f400   C5 17      CMP $17    ' compare with the just read ID2 of the header
.8:f402   D0 17      BNE $F41B  ' ID1 does not match, return error

.8:f404   4C 23 F4   JMP $F423  ' Now, check for READ code

...
.8:f410   A5 16      LDA $16    ' get ID1 from disc
.8:f412   85 12      STA $12    ' store as new ID1
.8:f414   A5 17      LDA $17    ' get ID2 from disc
.8:f416   85 13      STA $13    ' store as new ID2

.8:f418   A9 01      LDA #$01   ' 00, OK, 00, 00
.8:f41a   2C         .BYTE $2C  ' BIT 16 bit
.8:f41b   A9 0B      LDA #$0B   ' 29, DISK ID MISMATCH
.8:f41d   2C         .BYTE $2C  ' BIT 16 bit
.8:f41e   A9 09      LDA #$09   ' 27, WRITE ERROR
.8:f420   4C 69 F9   JMP $F969  ' Output message and quita

And the start of the read function is here:

.8:f4ca   C9 00      CMP #$00   ' is the job code $80? ($80-$80)
.8:f4cc   F0 03      BEQ $F4D1  ' yes, jump to READ code
.8:f4ce   4C 6E F5   JMP $F56E  ' now, test for WRITE

.8:f4d1   20 0A F5   JSR $F50A  ' ...
...


So, we see the big difference: While a seek is executed nevertheless if
we want to read, write, or do something else, there is a little bit
functionality that is only inherent in a seek: It gets the ID of the
disc and stores it into the "expected" ID (F410-F416). If this ID does
not match for every other command (tested in F3F2-F402), then we get a
29, DISK ID MISMATCH error code.

So, if there already was some activity on the disc and the disc was not
changed in between, then a seek is not needed as it is executed
nevertheless if needed. Anyway, if the disc might have changed or there
was no activity before, then you have to do a seek.

HTH,
   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.