Markus Rautopuro
Markus Rautopuro

Reputation: 8375

How can I use z88dk-z80asm preprocessor to expand a variable into a filename?

In z88dk-z80asm I want to include a binary file using a string literal, where a part of the file name is passed as a command line variable/symbol (-D) to the compiler:

binary "file_i_want_to_include_PARAMETER.bin" ; PARAMETER should be passed in command line

However, I can't figure out how to do this with z88dk-z80asm assembler preprocessor. You can do something like the following, but what would be the syntax on including the PARAMETER into the filename?

#define FILENAME "this-is-a-file-name.bin"
    binary FILENAME

The documentation introduces a token pasting operator ##, but it doesn't seem to handle quotes properly:

#define cat(a, b) a ## b
    cat(aa,bb)              ; expands to aabb

In M4 the following can be achieved like this:

define(DATAFILE, `"file_i_want_to_include_'PARAMETER`.bin"')
    binary DATAFILE

Is there a way to do this with the z88dk-z80asm preprocessor?

Upvotes: 0

Views: 15

Answers (0)

Related Questions