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

Re: EPZ directive



In article <1hgzz5r.mithx91cnuvy8N%dempson@actrix.gen.nz>,
 dempson@actrix.gen.nz (David Empson) wrote:

> John B. Matthews <nospam@nospam.com> wrote:
> 
> > In article <44913484$0$877$ba4acef3@news.orange.fr>,
> >  "Guillaume Tello" <houten.van@wanadoo.fr> wrote:
> > 
> > > hello,
> > > 
> > > i'm trying to learn 6502 asm. here is a part I don't understand:
> > > 
> > > B    EPZ $6    ; low part of adr
> > > BH    EPZ $7    ; high part of adr
> > > ...
> > >     LDA (B,X)
> > > 
> > > looking at the first two lines, I can think that the adr is $706.
> > > but the assembly code for LDA (B,X) is A1 06 meaning that only low part of
> > > the adress is used, pointing to page zero.
> > > 
> > You have stumbled upon the (little used) indexed indirect address mode.
> > In your example, the second byte of the instruction and the value in the
> > X register are added to to form a one-byte, zero-page address. The 
> > contents of that address and the one following become the 16-bit 
> > effective address from which the accumulator is loaded.
> 
> Right so far.
> 
> > Given
> > 
> > C  EPZ $8
> > CH EPZ $9
> > 
> > If X is zero, then LDA (B,X) acts like LDA $706.
> > If X is one,  then LDA (B,X) acts like LDA $807.
> > If X is two,  then LDA (B,X) acts like LDA $908.
> > etc.
> 
> No it doesn't.  EPZ doesn't cause anything to be stored in zero page
> locations. It just defines a symbol.
> 
> If X is zero, then LDA (B,X) acts like the 65C02 instruction LDA ($06).
> If X is one,  then LDA (B,X) acts like the 65C02 instruction LDA ($07).
> If X is two,  then LDA (B,X) acts like the 65C02 instruction LDA ($08).
> etc.
> 
> The actual locations accessed will depend on the values stored in the
> zero page locations.
> 
> Assuming the following data is stored:
> 
> 06: 11
> 07: 22
> 08: 33
> 09: 44
> 
> then:
> 
> If X is zero, then LDA (B,X) acts like LDA $2211
> If X is one,  then LDA (B,X) acts like LDA $3322
> If X is two,  then LDA (B,X) acts like LDA $4433
> etc.

Dave, thanks for clarifying this. I had badly confounded the zero-page 
address and its contents. Bad programmer; no caffeinated beverage! :-)

-- 
John Matthews
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/