Marat fayzullin's emulator source code says 2.
FCEUX source code says 3.
I have an old note on my emu source saying Bregalad said it takes 3 cycles.
But according to http://nesdev.com/6502_cpu.txt, all immediates take 2 cycles.
So what is it, 2 or 3?
Edit: it's 2 cycles, not 3.
AND Immediate, opcode $29, takes 2 or 3 cycles?
Moderator: Moderators
AND Immediate, opcode $29, takes 2 or 3 cycles?
Last edited by Petruza on Thu Jun 26, 2014 8:34 pm, edited 3 times in total.
Re: LDA Immediate, opcode $29, takes 2 or 3 cycles?
Opcode $29 is not LDA. (It's AND)
Re: LDA Immediate, opcode $29, takes 2 or 3 cycles?
I have no reason to doubt this favorite page for 6502 instructions: http://www.obelisk.demon.co.uk/6502/reference.html
It says 2 cycles for LDA Immediate. In fact, all immediate instructions are 2 cycles.
Would be nice if that page also had a section on illegal/undocumented/unofficial opcodes.
It says 2 cycles for LDA Immediate. In fact, all immediate instructions are 2 cycles.
Would be nice if that page also had a section on illegal/undocumented/unofficial opcodes.
Re: LDA Immediate, opcode $29, takes 2 or 3 cycles?
Why is this a poll? The amount of cycles a 6502 instruction takes to execute is a fact, and there's only one correct answer. There are no opinions here.
Re: LDA Immediate, opcode $29, takes 2 or 3 cycles?
Also, where exactly in FCEUX's source do you think it says AND #imm takes 3 cycles?
Re: AND Immediate, opcode $29, takes 2 or 3 cycles?
You're right, I thought of AND but wrote LDA.lidnariq wrote:Opcode $29 is not LDA. (It's AND)
Me neither, in fact I based my CPU emulator on that page.Movax12 wrote:I have no reason to doubt this favorite page for 6502 instructions: http://www.obelisk.demon.co.uk/6502/reference.html
Now that I reviewed FCEUX's source, it says 2.lidnariq wrote:Also, where exactly in FCEUX's source do you think it says AND #imm takes 3 cycles?
I had the cycle table copied from FCEUX, but I must have changed the 2 to 3 after I read in this forum that it was so (I commented in my code that Bregalad said that, but I could be wrong about that too) so I atributed the 3 to FCEUX, but it was actually me.
Mistery solved, thanks guys.
TL;DR: it's 2 cycles, not 3.
Edit: this is the post I'm talking about:
viewtopic.php?t=6183#p58516
Although now that I read it, by "and $xx" he might be referring to zero page, and not immediate, but AND zero page IS actually 3 cycles on that page.Bregalad wrote:... according to this. : http://www.6502.org/tutorials/6502opcodes.html
However this page contains at least 1 error : and $xx is 3 cycles and not 2...
Re: AND Immediate, opcode $29, takes 2 or 3 cycles?
I think I know where the confusion comes from: internally, the operation does indeed take three cycles, but the last cycle overlaps with fetching the next opcode, so effectively it behaves like it takes two cycles. I recall reading this in some C64 documentation.
Re: AND Immediate, opcode $29, takes 2 or 3 cycles?
OP has already figured out the answer, but I thought I'd write something coherent/definitive as a summary:
- Opcode $29, AND # (AND immediate) -- takes 2 cycles. I don't care what other documentation says; there are 6502 docs all over the place that have things wrong/typos/snakes in the grass. On the 6502 it's a 2-cycle opcode. If you're writing an emulator, or writing timing-sensitive code, it's 2 cycles.
- Opcode $A9, LDA # (LDA immediate) -- because it was mentioned earlier in the thread erroneously and I want to clarify -- takes 2 cycles.