This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

How to define a numeric constant in ca65?

How to define a numeric constant in ca65?
by on (#203792)
When I try to define a constant as simple number what I get is either an error or a memory address, no matter what I try. What am I doing wrong?

According to this page doing this: "two = 2" would define "two" as a numeric constant, but when I do that what I get is the address $2, not the number #2. If I try "two = #2" I get "trailing garbage characters" error.

ca65 is v2.16

edit: apparently this feature is only for cc65? Is that correct? Is there a way to do it on ca65?
Re: How to define a numeric constant in ca65?
by on (#203795)
This is probably what you want:
Code:
two = 2
lda #two

This is possible, but NOT recommended:
Code:
.define two #2
lda two
Re: How to define a numeric constant in ca65?
by on (#203798)
Precisely, thanks! That works fine. :beer: