[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 6502 false references?



In article <462ah4$as_001@news.usa.net>,
The Blue Meanie <jnoyes@usa.net> wrote:
> In article <45ulkp$ppd@post.gsfc.nasa.gov>,
>    klipsch@ssvs.gsfc.nasa.gov (Colin Klipsch) wrote:
> ...
> >My question is: which 6502 instructions generate double references?  More
> >specifically, which instructions will hit the speaker twice instead of
> >once, when applied to the speaker I/O addresses?  I've looked in
> >Leventhal's and Zak's 6502 books, but didn't find this information.
> >(Perhaps I overlooked it...?)
> ...
> 
> The way I remember my 6502 programming, ANY write instruction to a
> given memory location generated a dual reference (A read always
> preceded a write)

Nope.  STA absolute, for example, takes 4 cycles.  They are: opcode
fetch, operand fetch (low), operand fetch (high), data write.

An indexed write will generate a false read of the destination
location (or the same location one page earlier if the index crosses
the page boundary).

Examples:

    STA $C089,X

        Assuming X=$60, this will take 5 cycles.  A read of $C0E9 will
        occur, followed by a write.  (This is the Disk ][ "motor on"
        location for slot 6).

    STA $02F0,X

        Assuming X=$20, this will take 5 cycles.  A read of $0210 will
        occur, followed by a write to $0310.

    STA ($3C),Y

        Assuming locations $3C and $3D point to $C030, and Y contains 0,
        this will take 6 cycles.  A read of $C030 will occur, followed
        by a write.  This is the general type of operation performed by
        the POKE command in BASIC, which is why you cannot use a POKE to
        activate the speaker (but a STA from machine code is fine) - the
        read and write on adjacent cycles are too close together to get
        any sound of the speaker.
-- 
David Empson
dempson@actrix.gen.nz
Snail mail: P.O. Box 27-103, Wellington, New Zealand