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.
I was a bit curious as to the usage of zero-page addressing by the NESASM3 compiler and after doing a little digging it appears it does not use zero page. I uncovered this:
I think it requires you to use special syntax with the Low Byte ( < ) operator. Something like #<$40 or something, but this is just what I remember hearing about that tool. I just use ASM6 and not worry about that kind of stuff.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Dwedit wrote:I think it requires you to use special syntax with the Low Byte ( < ) operator. Something like #<$40 or something, but this is just what I remember hearing about that tool. I just use ASM6 and not worry about that kind of stuff.
That worked like a charm, although in this situation I was using labels and not simply LDA $40 but either way, putting a < in front of the address like <$40 or <Label makes the compiler use zero-page.
I find it odd that something like that isn't there by default. I mean it isn't all that hard to check if an address is zero-page. I don't suppose NESASM3 is open-source?
Dwedit wrote:I just use ASM6 and not worry about that kind of stuff.
ASM6 will use ZP addressing whenever possible... If you don't want to use ZP addressing, you have to enter the instruction manually or use a mirror. On the NES you can just add $800 to the address, since $0800-$08FF is a mirror of $0000-$00FF.
I think bunnyboy's been updating it when the mood strikes him.
The version number went from v2.51 to v3.01, despite that it only seems to be a bugfix for a single bug (a really bad one though).
It's definitely recommended to use ASM6. Especially if you want to release any source codes. NESASM usually works, but is pretty weird as far as assemblers go. I especially never liked ones that require more verbose sources for mundane tasks like that (TASM, WLA-DX are a couple others).
67726e wrote:When would you not want to use zero-page addressing? I mean so far as I know, wouldn't you want to use fastest solution?
The only situation I can think of is Self Modifying code, or crazy situations where you are intentionally executing a garbage instruction to avoid a branch.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
I used absolute mode for a zeropage address at least once, in a timed loop where I needed to use up a single CPU cycle. That was pretty much the only way to do that.
Yup, timed code. Using Absolute addressing instead of ZP is the simplest way to waste a single cycle. There might not be much need for that on the NES, but on the Atari 2600 there surely is.
I do have some timed code in my current NES project (because of my NMI handler, which always takes the same amount of time regardless of the tasks it performs), but I don't think I had to use this particular trick.
Doesn't NESASM use []s for indirection? The 6502 doesn't have an indirect mode that's not indexed (the 65C02 does, though), so LDA [$XX] should not be a valid instruction. If that's working for you, that's probably just NEASM being weird again. The correct way to use ZP addressing in NESASM is by using "<" before the variable/address.
Last edited by tokumaru on Wed Dec 08, 2010 8:35 pm, edited 1 time in total.
3gengames wrote:I am pretty sure. I've never checked the hex with LDA ($00) though so I am not sure it throws ZP into that or not.
Wait a minute! Do you use [] or ()? If you are using parenthesis (which NESASM doesn't use for indirection, unlike all other 6502 assemblers), then it's probably generating absolute addressing instructions. For the program logic it makes no difference, so you can't tell unless you look at the binary. LDA $0000 works exactly the same as LDA $00, it just takes longer.
Let me check? I also use []'s. Not (). () don't throw errors, it might ignore them possibly, causing the zeropage value not to be used?
LDA makes $AD 0000, LDA [$00] makes $B200 (Says UNDEFINED and then BRK instructions), LDA ($00) makes $AD 0000, LDA [$00],Y makes $B1 00, LDA ($00),Y makes $B9 0000. And for some reason, when the debugger for FCEUXD look at the LDA ($00),Y it says @ $0000,Y and says it's pointing to location $0000. >.<
I need to make a better test, but that doesn't seem right. :/ I've used ZP though, and it worked. I used [$##]. It even worked on hardware. 0_0