[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LDA C08C,X
In article <Pine.A41.4.44.0302241024550.125040-100000@zivunix.uni-muenster.de>,
Holger Picker <pickerh@uni-muenster.de> writes:
>the code example is taken from the disk][ slot rom. The full code for
>reading the sector header is as follows:
>
>$c65c:
>waitforsector: CLC ; clear carry to indicate waiting for sector
header
> PHP ; save carry
>waitford5: LDA $c08c,x
> BPL waitford5
>testford5: EOR #$d5
> BNE waitford5
>waitforaa: LDA $c08c,x
> BPL waitforaa
> CMP #$aa
> BNE testford5; if not $aa, maybe $d5 again?
> NOP ; just a short delay
>waitfor96: LDA $c08c,x
> BPL waitfor96
> CMP #$96
> BEQ continue_with_reading_address_field
> PLP ; get carry again
> BCC waitforsector
> EOR #$ad
> BEQ continue_with_reading_data_field
> BNE waitforsector; jump always
>
>As you can see, the following instructions after testford5 will destroy
>both, the accumulator (LDA $c08c,x) and the carry bit (CMP #$aa). For this
>reason, it is not necessary to use "EOR #$d5" instead of "CMP #$d5". (As a
>matter of fact, I have written a RWTS which puts "CMP #$d5" here, and it
>does work. :-) In addition, I've also verified this on my emulator by
>changing
>EOR to CMP.) My guess is that the programmer just wanted to show a
>difference between the instructions "EOR #$d5" and "CMP #$aa", because "EOR
>#$d5" will be executed again after the test "CMP #$aa" failed. Otherwise
>there does not seem to be any reason for this.
>BTW.: What I find interesting here is that the program will look again for
>the sector header if reading the data header fails, although the sector
>header has been found already, i.e. at $c681 (BNE waitforsector) the program
>will jump to address $c65c instead of $c65d.
If the third header nibble is not a $96 (for an address mark) and not an
$AD (for a data mark), then we have not correctly recognized _either_
header, and we should start over, looking for an address mark.
-michael
Check out amazing quality 8-bit Apple sound on my
Home page: http://members.aol.com/MJMahon/