This sounds right now that you say it :-) I even
considered it yesturday, but I wasn't sure $00 was a valid high byte for
whatever reason.
My main confusion comes from 6502.org's explanation
of
LDA
Affects Flags: S Z MODE SYNTAX HEX LEN TIM
Immediate LDA #$44 $A9 2 2
Zero Page LDA $44 $A5 2 3
Zero Page,X LDA $44,X $B5 2 4
Absolute LDA $4400 $AD 3 4
Absolute,X LDA $4400,X $BD 3 4+
Absolute,Y LDA $4400,Y $B9 3 4+
Indirect,X LDA ($44,X) $A1 2 6
Indirect,Y LDA ($44),Y $B1 2 5+ This lead me to believe only the low byte is used. Silly me --Chris
----- Original Message -----
Sent: Tuesday, October 07, 2003 8:07
PM
Subject: Re: [stella] My code is
broked!
Hi,
I'm still learning Indirect Y addressing (and
writing a "how to" as I go along in case I forget later) but I think you may
need to initialize both the hi and lo byte of the address (since Indirect Y
expects a 16-bit address).
For example, you're stuffing the value #$B0
(least significant byte of the address) in tmpVar3 but when you go to
dereference it later (with "lda (tmpVar3),y"), it's reading the address as
"$xxB0" where "$xx" is garbage.
Try this...
lda
#PlayerHand sta tmpVar3 lda #0 sta tmpVar3+1
lda
#Player3 sta tmpVar4 lda #0 sta tmpVar4+1
We're simply putting
"$00" as the most significant byte of the address so the tmpVar3 pointer will
look like "$00B0" and the tmpVar4 pointer will hold "$00A0". Oh, and be sure
both tmpVars are 2 bytes in size!
I hope that helps. If not, we'll both
learn something! :)
Jason
On Tuesday, October 7, 2003, at
07:33 PM, Chris Larkin wrote:
It could just be that I
still don't fully understand indirect addressing... But this should work?/smaller>/fontfamily> I
know this loop does not replace the first byte in either location, but it
should "swap" the others... However/smaller>/fontfamily> my
results are not very good :-) What am I doing wrong?/smaller>/fontfamily> PlayerHand
= $B0 ; -> $B6/smaller>/fontfamily> Player3
= $A0 ; -> $A6 /smaller>/fontfamily> TradeHands
LDY #7 LDA
#PlayerHand STA tmpVar3
LDA #Player3 STA tmpVar4/smaller>/fontfamily>
TradeLoop
LDA (tmpVar3),y STA
tmpVar2 LDA
(tmpVar4),y STA
(tmpVar3),y LDA
tmpVar2 STA (tmpVar4),y
DEY BNE TradeLoop
RTS/smaller>/fontfamily>
|