Page 1 of 1

= vs. :=

Posted: Wed May 25, 2022 6:19 pm
by jeffythedragonslayer
What is the motivation in ca65 behind having both = and := for numeric constants?
The documentation says := marks the symbol as a label "so it may be handled differently in a debugger"

https://cc65.github.io/doc/ca65.html#ss6.1

What does that mean; different how?

Re: = vs. :=

Posted: Wed May 25, 2022 9:36 pm
by drogon
jeffythedragonslayer wrote:
What is the motivation in ca65 behind having both = and := for numeric constants?
The documentation says := marks the symbol as a label "so it may be handled differently in a debugger"

https://cc65.github.io/doc/ca65.html#ss6.1

What does that mean; different how?
My understanding is that labels are present in the output files (before linking) and so a debugger can find them and you can refer to them when linking with other files.

Using = just creates a name while that file is being assembled an doesn't create the label for any subsequent debugger to find.

The upshot is (AIUI), using = will produce smaller .o files which may assemble and/or link faster, but it's not something I've really cared about.

If you want symbols to be global over several files, then use := else use =

-Gordon

Re: = vs. :=

Posted: Wed May 25, 2022 11:59 pm
by jmthompson
drogon wrote:
If you want symbols to be global over several files, then use := else use =
Hmm, except it seems you can still export symbols even with defined with "=". In my monitor code, I have this in one file:

Code: Select all

.export IBUFFSZ

IBUFFSZ = 256
and I am able to import and use that just fine. Honestly when I wrote it that way I didn't expect it to work, but it does, so I just left it alone.

In general I just tend to declare constants with "=" and actual addresses/symbols with ":=", but I think that's mostly just a personal thing for me and I'm not sure it really makes a difference.