[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LDA C08C,X
On Mon, 24 Feb 2003, Doug Kwan wrote:
> Date: Mon, 24 Feb 2003 04:15:10 GMT
> From: Doug Kwan <NOSPAMdkwan@gauge.transmeta.com>
> Newsgroups: comp.sys.apple2
> Subject: Re: LDA C08C,X
>
> Bryan Parkoff <BParkoff@satx.rr.com> wrote:
> : Please explain what LDA C08C,X is. I know that it is read mode into
> : byte latch. Please look below:
>
> : C65E: BD 8C C0 LDA C08C,X
>
> : C661: 10 FB BPL C65E {-05}
>
> : C663: 49 D5 EOR #D5
>
> : It requires to loop until bit is high. Does it mean that it has to loop
> : 8 times until 8 bits are filled in a byte latch? Is it possible to add "STA
> : 4000" between LDA and BPL so I can see one bit out of 8 bits into one byte
> : storage? Why do EOR #D5 have to be used instead of CMP like AA and 96.
> : I do have Beneath Apple DOS/ProDOS manual in front of me, but it does
> : not provide me enough information. It is why I am asking a question in
> : newsgroups so someone might be able to provide more information. I
> : appreciate this.
>
> EOR does not change the carry bit in the status register but CMP does.
> RWTS uses the carry flag to signify error in many places. That may be the
> reason.
>
> -Doug
>
> ------------------------------------------------------------------
> Remove the obvious to get my e-mail address.
>
>
Hi,
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.
Holger
- References:
- LDA C08C,X
- From: "Bryan Parkoff" <BParkoff@satx.rr.com>
- Re: LDA C08C,X
- From: Doug Kwan <NOSPAMdkwan@gauge.transmeta.com>