nesdev.com
http://forums.nesdev.com/

A small problem with a LDA opcode
http://forums.nesdev.com/viewtopic.php?f=10&t=16643
Page 1 of 2

Author:  kuja killer [ Mon Oct 30, 2017 2:15 pm ]
Post subject:  A small problem with a LDA opcode

Hello, im posting again with a little tiny problem i have involving Zero Page ... Y register

Sometimes i need to use a LDA "zero page" RAM in some places, which is "B9 xx 00"
the problem is, i cant figure out how to actually do it, cause i always get "incorrect addressing mode" error no matter what i try, how many times i try.

This is for "NESASM 2.51 autoZP" version. i dont know if it's a bug or not. :( The only way i can ever make it work is by manually typing out a .db command with the actual hex numbers.

I tried LDA ($41),y ... LDA [$41],y ... LDA ($41,y) ...LDA [$41,y] ... the weird accented brackets like { and } ...i tried everything i can possibly think of and nothing works :( except just a plain .db only
is there some way to do it ??

Image

Author:  Lazycow [ Mon Oct 30, 2017 2:21 pm ]
Post subject:  Re: A small problem with a LDY opcode

there's no LDY $xxxx,y

Author:  kuja killer [ Mon Oct 30, 2017 2:26 pm ]
Post subject:  Re: A small problem with a LDY opcode

huh ??
Well it does exist in the NES for reals though :|
Image

or ...just doesnt exist in the NESASM 2.51 "only" ?? :|

Author:  lidnariq [ Mon Oct 30, 2017 2:31 pm ]
Post subject:  Re: A small problem with a LDY opcode

kuja killer wrote:
LDY ($41),y ... LDY [$41],y ... LDY ($41,y) ...LDY [$41,y]

Lazycow wrote:
there's no LDY $xxxx,y

kuja killer wrote:
[Picture of LDA $0041,Y]

Author:  rainwarrior [ Mon Oct 30, 2017 2:38 pm ]
Post subject:  Re: A small problem with a LDY opcode

For a good comprehensive reference on which instructions exist, I recommend this:
http://www.obelisk.me.uk/6502/reference.html#LDY

$B9 is LDA absolute, Y though; it is neither LDY nor zero page. You can point absolute addresses at the zero page if you need to, however.

There is a LDX/STX zero page, Y, which I think is the only instruction with that kind of addressing?

Author:  kuja killer [ Mon Oct 30, 2017 2:40 pm ]
Post subject:  Re: A small problem with a LDY opcode

oops first of all, sorry i said it wrong when i started this topic, i meant LDA, not LDY, my mistake.
Bottom line, i was trying to get "B9 xx 00" ...like if i try LDA (not y sorry above) ...it'll come out as "B1 41" which is not what i wanted. when it needed to be " B9 "

i supposed i could just do like "LDA label name + $800" to use that so called "mirrored" RAM thing, (so that i can get rid of the raw hex numbers) ??

Author:  Sumez [ Mon Oct 30, 2017 2:43 pm ]
Post subject:  Re: A small problem with a LDY opcode

I think this is what you want:

LDA $0041,Y

Author:  rainwarrior [ Mon Oct 30, 2017 2:45 pm ]
Post subject:  Re: A small problem with a LDY opcode

kuja killer wrote:
oops first of all, sorry i said it wrong when i started this topic, i meant LDA, not LDY, my mistake.
Bottom line, i was trying to get "B9 xx 00" ...like if i try LDA (not y sorry above) ...it'll come out as "B1 41" which is not what i wanted. when it needed to be " B9 "

i supposed i could just do like "LDA label name + $800" to use that so called "mirrored" RAM thing, (so that i can get rid of the raw hex numbers) ??

On NESASM, I think $B1 should only happen if you put [] around the address?

$B1 is LDA (indirect), Y

Most assemblers use () for indirection syntax, but NESASM uses [] instead.

Edit: apparently this specific version of NESASM uses () instead of [].

Author:  tepples [ Mon Oct 30, 2017 2:48 pm ]
Post subject:  Re: A small problem with a LDA opcode

LDA $41,Y (B9 41 00) calculates the effective address by adding Y to $0041.

LDA [$41],Y (B1 41) calculates the effective address by reading the bytes at $0042 and $0041, forming a 16-bit number out of them, and adding Y.

If NESASM is assembling LDA $41,Y as B1 41, it is misbehaving. Auto-ZP should not activate for aaaa,Y mode unless the instruction is LDX, which is the only official instruction on the 6502 to have both aaaa,Y and dd,Y versions.

Author:  kuja killer [ Mon Oct 30, 2017 3:05 pm ]
Post subject:  Re: A small problem with a LDA opcode

hmm yea i get what ya guys are saying.
well.. i guess maybe it is a bug then probably, cause yea i use this type of NESASM's "auto zp" thing so that i dont ever have to type any of those " > arrow " things next to zero page lables and stuff

but i guess it wouldnt work only with the B9 ..but ehh

96 28:009C LDA Test1,y
Incorrect addressing mode! ww

well, this is not very pretty looking but this does work:
I've never once in my life used that "mirrored ram" that goes past $800, like this..

is it "NES Safe" to do this $800 ??

Image

Author:  rainwarrior [ Mon Oct 30, 2017 3:09 pm ]
Post subject:  Re: A small problem with a LDA opcode

Yes it's safe but it's "unusual" and there's no reason that this shouldn't produce $B9 $41 $00:
LDA Test1,y

It will only produce $B1 if you put brackets [] in there.

Edit: for this version of NESASM, it is () instead of [].

Author:  thefox [ Mon Oct 30, 2017 3:26 pm ]
Post subject:  Re: A small problem with a LDA opcode

For reference, he's using this version: http://www.2a03.jp/~minachun/nesasm/nesasm_x86.html

And looks like it has a bug where it refuses to assemble lda $69, y (it says "Incorrect addressing mode!"). It's fine with lda $6969, y.

That version also enables parenthesis () to be used instead of brackets [] in indirect addressing.

Author:  kuja killer [ Mon Oct 30, 2017 4:40 pm ]
Post subject:  Re: A small problem with a LDA opcode

yea what fox said, i tried all the "label,y" like rainwarrior said, and tons of different ways, and either end up with B1 ...or "incorrect addressing mode" every time.

so finally i just was like screw it and did the +$800 thing.
I went through and replaced all the ".db $B9, xx, 00" with "LDA label+$800,y" instead ...had about 10 of these throughout a whole lot of ASM files

Author:  rainwarrior [ Mon Oct 30, 2017 6:25 pm ]
Post subject:  Re: A small problem with a LDA opcode

Ah, well that explains the problem. LDA abs, Y is broken in this assembler if the address is less than $100?

I guess the only thing I'd recommend is to report the bug and/or find a better assembler. If using +$800 gets you through your current project, though, that's fine too.

Whenever you use () around the address for LDA it should produce $B1, so that part is working fine. (Sorry I incorrectly said [] before, I didn't realize this was a special version of NESASM.)

Author:  kuja killer [ Mon Oct 30, 2017 7:12 pm ]
Post subject:  Re: A small problem with a LDA opcode

i would more than love to be able to just fix it myself in this nesasm 2.51, though i dont know any programming languages whatsoever besides NES's 6502 stuff. :|

And since that was made in 2011 apparently...i would not be able to use a different assembler because i have a couple files from the author of Rockman 4 Minus Infinity (puresabe) that i use, ..which were formatted specifically only for NESASM, i dont have a clue how they would be made to work with ASM6 or whatever.

Page 1 of 2 All times are UTC - 7 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/