ca65 changing address size of a symbol?

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

ca65 changing address size of a symbol?

Post by GradualGames »

The ca65 docs say:

Code: Select all

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.
User avatar
dustmop
Posts: 136
Joined: Wed Oct 16, 2013 7:55 am

Re: ca65 changing address size of a symbol?

Post by dustmop »

Have you tried colon (:)? Like ".export symbol : absolute". Not sure if it works with .global
User avatar
GradualGames
Posts: 1106
Joined: Sun Nov 09, 2008 9:18 pm
Location: Pennsylvania, USA
Contact:

Re: ca65 changing address size of a symbol?

Post by GradualGames »

Perfect, that worked! Thanks sir.
User avatar
rainwarrior
Posts: 8734
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: ca65 changing address size of a symbol?

Post by rainwarrior »

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
Post Reply