Why does TXA bring up a syntax error? -Easy6502

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
User avatar
2fadfe
Posts: 17
Joined: Thu Feb 24, 2022 7:55 pm
Location: Earth

Why does TXA bring up a syntax error? -Easy6502

Post by 2fadfe »

https://skilldrick.github.io/easy6502/#addressing
I was at this point in the book and already did exercises 2 & 3, but when I tried to use any of the transfer opcodes I get a syntax error:

Code: Select all

LDA #$01
STA $01
LDX #$02
STX $01
TXA #$02
BRK
results:
Preprocessing ...
Indexing labels ...
Found 0 labels.
Assembling code ...
**Syntax error line 5: TXA #$02**
Known as Duncan Idaho #0087 on the Discord Server.
User avatar
gauauu
Posts: 779
Joined: Sat Jan 09, 2016 9:21 pm
Location: Central Illinois, USA
Contact:

Re: Why does TXA bring up a syntax error? -Easy6502

Post by gauauu »

TXA and the like (TAY, TYA, etc) transfer the existing value from one register to another (from X to A in the case of TXA), so they never take an operand.

Code: Select all

ldx #5
txa
Now the accumulator has the value 5.
User avatar
Quietust
Posts: 1920
Joined: Sun Sep 19, 2004 10:59 pm
Contact:

Re: Why does TXA bring up a syntax error? -Easy6502

Post by Quietust »

The "Instructions" section demonstrates using "TAX" with no operand:

Code: Select all

LDA #$c0  ;Load the hex value $c0 into the A register
TAX       ;Transfer the value in the A register to X
INX       ;Increment the value in the X register
ADC #$c4  ;Add the hex value $c4 to the A register
BRK       ;Break - we're done
The first Exercise at the bottom of that section says "You’ve seen TAX. You can probably guess what TAY, TXA and TYA do, but write some code to test your assumptions.", which implies that TXA also takes no operand, so why were you trying to use it with one?
Quietust, QMT Productions
P.S. If you don't get this note, let me know and I'll write you another.
User avatar
2fadfe
Posts: 17
Joined: Thu Feb 24, 2022 7:55 pm
Location: Earth

Re: Why does TXA bring up a syntax error? -Easy6502

Post by 2fadfe »

I don't know why I was trying to use TXA with an operand. Thank you guys for clarifying- even though it was right under my nose. :x
Last edited by 2fadfe on Fri Feb 25, 2022 8:37 am, edited 2 times in total.
Known as Duncan Idaho #0087 on the Discord Server.
Post Reply