= vs. :=

Building your first 6502-based project? We'll help you get started here.
Post Reply
jeffythedragonslayer
Posts: 114
Joined: 03 Oct 2021

= vs. :=

Post 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?
User avatar
drogon
Posts: 1671
Joined: 14 Feb 2018
Location: Scotland
Contact:

Re: = vs. :=

Post 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
--
Gordon Henderson.
See my Ruby 6502 and 65816 SBC projects here: https://projects.drogon.net/ruby/
jmthompson
Posts: 127
Joined: 30 Dec 2017
Location: Detroit, Michigan, USA
Contact:

Re: = vs. :=

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