EDIT: PLEASE NOTE: This thread is somewhat redundant, and turned out to be the same issue I brought up here 5 years ago. I had a .scope ... .endscope in my macro, and this introduced the problem in places where it hadn't previously existed.
I have a macro which contains the following code:
ins arg+1
Where ins is a 6502 instruction passed in as an argument to the macro, and arg is a symbol in zp or ram.
I noticed it is always generating absolute addressing for symbols in zp with this expression. Yet the documentation says:
"If this is not the case, and the expression contains a symbol, explicitly declared as zero page symbol (by one of the .importzp or .exportzp instructions), then the whole expression is assumed to be byte sized."
I would assume that "contains a symbol" means that the +1 shouldn't make it fail to generate a zp instruction.
To work around this, I can declare lo and hi byte for all word zp variables so I don't need the + 1. Then I successfully get zp instructions generated where I expect. But it doesn't seem like this ought to be necessary given what the documentation says.
Interestingly contrasting the performance between the two, I'm not seeing a huge savings ensuring zp instructions in these cases. I'm guessing because these macros are typically used in higher-level situations than the most performance intensive parts of my game.
I have a macro which contains the following code:
Code:
ins arg+1
Where ins is a 6502 instruction passed in as an argument to the macro, and arg is a symbol in zp or ram.
I noticed it is always generating absolute addressing for symbols in zp with this expression. Yet the documentation says:
"If this is not the case, and the expression contains a symbol, explicitly declared as zero page symbol (by one of the .importzp or .exportzp instructions), then the whole expression is assumed to be byte sized."
I would assume that "contains a symbol" means that the +1 shouldn't make it fail to generate a zp instruction.
To work around this, I can declare lo and hi byte for all word zp variables so I don't need the + 1. Then I successfully get zp instructions generated where I expect. But it doesn't seem like this ought to be necessary given what the documentation says.
Interestingly contrasting the performance between the two, I'm not seeing a huge savings ensuring zp instructions in these cases. I'm guessing because these macros are typically used in higher-level situations than the most performance intensive parts of my game.