NESASM forces absolute addressing in zero page

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

User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NESASM forces absolute addressing in zero page

Post by tokumaru »

Yes, this and other workarounds have been suggested. It's not like this is impossible to do, but the code is more readable if you don't have to do things like this, and not having to look up opcodes will save some time too.
3gengames
Formerly 65024U
Posts: 2284
Joined: Sat Mar 27, 2010 12:57 pm

Re: NESASM forces absolute addressing in zero page

Post by 3gengames »

Would the preferred solution to be an assembler that optimizes all instructions for zeropage unless the object is denoted with a $ character preceding the object's name/value? :)
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NESASM forces absolute addressing in zero page

Post by tepples »

$ is reserved for the hexadecimal constant prefix. I've seen that ca65 optimizes where possible (address is known to be less than $100 before it is used) unless a: is specified.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NESASM forces absolute addressing in zero page

Post by tokumaru »

A modifier is certainly the best solution, because it can be applied to anything (hardcoded addresses, variables and expressions) but I never heard of this syntax before (a:). Is it common or just a CA65 thing? I've seen .w appended to the operator a few times before, so I'm not sure which is more common. When you force an addressing mode like this, you're in fact modifying both the operator (different opcode) and the operand (16 bits instead of 8), so both make sense to me.
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: NESASM forces absolute addressing in zero page

Post by tepples »

In 68000 assembly, instructions use .W and the like to specify the size of the data (8, 16, or 32 bits), not the size of the address.
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: NESASM forces absolute addressing in zero page

Post by tokumaru »

tepples wrote:In 68000 assembly, instructions use .W and the like to specify the size of the data (8, 16, or 32 bits), not the size of the address.
If that's the case, then this really isn't the best option for 6502 assembly.
tomaitheous
Posts: 592
Joined: Thu Aug 28, 2008 1:17 am
Contact:

Re: NESASM forces absolute addressing in zero page

Post by tomaitheous »

Doesn't ASM6 support macros? It shouldn't be too difficult to write macros for instructions that need to read/write full address or zp addressing.
__________________________
http://pcedev.wordpress.com
zzo38
Posts: 1096
Joined: Mon Feb 07, 2011 12:46 pm

Re: NESASM forces absolute addressing in zero page

Post by zzo38 »

Just let it known that I personally happen to prefer the way NESASM does it; zero page addressing is marked explicitly.
(Free Hero Mesh - FOSS puzzle game engine)
keldon
Posts: 8
Joined: Wed Jun 07, 2017 7:55 am

Re: NESASM forces absolute addressing in zero page

Post by keldon »

How about:

Code: Select all

LDA (zeroPageAddress + $800), y
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NESASM forces absolute addressing in zero page

Post by rainwarrior »

That's not a valid 6502 instruction. The value within () needs to be < $100. There is no indirect indexed LDA that takes a pointer from outside the zero-page. (Only indirect JMP can do this.)

LDA (zp), Y
keldon
Posts: 8
Joined: Wed Jun 07, 2017 7:55 am

Re: NESASM forces absolute addressing in zero page

Post by keldon »

My bad I meant:

Code: Select all

LDA zeroPageAddress+$800, y
To force opcode $B9.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: NESASM forces absolute addressing in zero page

Post by rainwarrior »

Well, yes you can use mirrored addresses for ZP on the NES, though I don't think it's a good way to do this.

In NESASM it will be absolute anyway if you don't use the < prefix, so it's not relevant.

On ca65 you can force an absolute address with an a: prefix. I think it's better to use this instead of relying on mirroring.

Code: Select all

LDA a:zeroPageAddress, y
User avatar
morskoyzmey
Posts: 13
Joined: Sat Sep 15, 2018 2:59 pm

Re: NESASM forces absolute addressing in zero page

Post by morskoyzmey »

For those who found this thread.
I have a patch barely discussed in this topic
I'd like to get some feedback, and I could fix it to fit community needs.
Post Reply