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

ca65 changing address size of a symbol?
http://forums.nesdev.com/viewtopic.php?f=2&t=15526
Page 1 of 1

Author:  GradualGames [ Sun Feb 12, 2017 10:57 am ]
Post subject:  ca65 changing address size of a symbol?

The ca65 docs say:

Code:
ca65 assigns each segment and each symbol an address size. This is true, even if the symbol is not used as an address. You may also think of a value range of the symbol instead of an address size.

Possible address sizes are:

Zeropage or direct (8 bits)
Absolute (16 bits)
Far (24 bits)
Long (32 bits)
Since the assembler uses default address sizes for the segments and symbols, it is usually not necessary to override the default behaviour. In cases, where it is necessary, the following keywords may be used to specify address sizes:

DIRECT, ZEROPAGE or ZP for zeropage addressing (8 bits).
ABSOLUTE, ABS or NEAR for absolute addressing (16 bits).
FAR for far addressing (24 bits).
LONG or DWORD for long addressing (32 bits).



How do you use these keywords? I've tried placing them before, between, and after a symbol definition as well as a symbol import, and also with and without a "." preceding. So it feels as though I've tried every permutation possible for applying these keywords, however ca65 was not happy with any given attempt.

The particular use case is I'm trying to get rid of a warning from ld65 saying my symbol is exported as zp but imported as absolute. I'm using .global to both import and export the symbol. It's happening because I'm tracking start and end locations of chr chunks in a CHR-ROM segment, where the address space starts at $0, so I assume that's why the assembler/linker is assigning zeropage in one case but doesn't know what to do in the other case.

Author:  dustmop [ Sun Feb 12, 2017 11:14 am ]
Post subject:  Re: ca65 changing address size of a symbol?

Have you tried colon (:)? Like ".export symbol : absolute". Not sure if it works with .global

Author:  GradualGames [ Sun Feb 12, 2017 11:19 am ]
Post subject:  Re: ca65 changing address size of a symbol?

Perfect, that worked! Thanks sir.

Author:  rainwarrior [ Sun Feb 12, 2017 1:37 pm ]
Post subject:  Re: ca65 changing address size of a symbol?

Alternatively there's .importzp / .exportzp / .globalzp as a shorthand.

If you want to read the documentation about it:
http://cc65.github.io/doc/ca65.html#ss11.39

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