[cc65] .IFDEF, .DEFINED for checking existance of macros?

From: Gábor Lénárt <lgb1lgb.hu>
Date: 2011-11-28 15:50:50
Hi,

Is there a way to do conditional assembly based on the fact that a macro is
defined? It seems .IFDEF or .DEFINED does not work with macros, at least
I got errors. I would need something like this (sorry if the syntax is not
correct, I have not the source at this moment, so it's only by heart - but
I remember that theory does not worked even with the correct syntax - as I
could extract from the documentation at least):


.DEFINE file_name "filename.dat"  ; comment this out to use the disk-loader

.BSS
.IFNDEF (file_name)
my_data: RES 8192	; if file_name is not defined, I just reserve space,
			; I will load the data from disk on run-time
.ENDIF

.CODE
.IFDEF (file_name)
my_data: .INCBIN file_name  ; include the "built-in" version
.ENDIF

.IFNDEF(file_name)
; routines to load from disk: only needed to compile if we don't use the included version
.ENDIF

id_marker = my_data + $10
version_byte = my_data + $11

main:
... some code ...
.IFNDEF(file_name)
JSR disk_loader
.ENDIF
... some code ...


My goal is to have a single source to have a music player which can play an
song included (with .INCBIN, I meant) as a quick demo, but also it can be
compiled with a minor modification (commenting out the .DEFINE) to be able
to load song from disk: and only then the routines needed for this is
compiled. Also, I have constants (my_data + ...) which should be correct for
both cases.

Is it possible somehow? Sorry form my chaotic example, but hopefully my idea
is understandable at least.

As far as I remember (the source is at home now) I always get errors even if
I try syntax directly copy&pasted from the documentation. Are these .DEFINED
etc built-in functions can only be used within macros (for macro parameters
maybe ...), or some special cases, so it's not suitable for the purpose I want to use?

thanks!

- Gábor
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Nov 28 15:50:59 2011

This archive was generated by hypermail 2.1.8 : 2011-11-28 15:51:02 CET