Reputation: 604
SDCC's assembler is derived from ASxxxx where manual describes the .define command here: http://shop-pdp.net/ashtml/asxs02.htm#define
Since it's a derivation it's possible not everything works the same way, but since the command line argument help talks about .define ("-b Display .define substitions in listing") I'd assume they are there.
However, when I do:
.define ay /-1/
I get the error:
g.s:1: Error: <o> .org in REL area or directive / mnemonic error
Other forms I've tried include:
.define ay ^/-1/
.define ay "-1"
.define kword /foo/
All of those result int he same error. If I try
.define
the error becomes:
g.s:1: Error: <q> missing or improper operators, terminators, or delimiters
I get that same error with .blarg
though, so it's possible the keyword has been removed (why though?)
Am I doing something wrong, or is sdasz80 just broken?
Upvotes: 3
Views: 742
Reputation: 3222
I have just stumbled on this problem, and have created a bypass solution.
I wrote a tiny wrapper in python that does the preprocessing and calls the assembler, making it transparent to the user.
https://gist.github.com/amirgeva/45e8616f62622016eb7ee083c9cac209
Upvotes: 1
Reputation: 663
For many purposes you can use variables. This will work on sdasz80 (SDCC revision)
SOME_IO_ADDRESS = 0x32
[...]
LD A, #0xAA
OUT (#SOME_IO_ADDRESS), A
Upvotes: 1
Reputation: 480
Take also into account that sdasz80 shipped along with SDCC is an old version of ASxxxx. In fact, the documentation they ship with their sdasz80 is for a newer version of ASxxxx and some features are actually not present in the version shipped.
If you want those features and newer ones, you may download an updated version of ASxxxx from its website. There have been many newer versions including docens of new interesting features. Latest version is from January 2019: http://shop-pdp.net/ashtml/asxxxx.php
Upvotes: 1
Reputation: 604
Well crap, it seems it's a feature they removed for some reason. Searching through the github mirror of SDCC's sources (sdas sources here: https://github.com/svn2github/sdcc/tree/master/sdcc/sdas) SDCC's asxxxx.h (last edited 6 years ago) has this block:
/*
* The def structure is used by the .define assembler
* directive to define a substitution string for a
* single word. The def structure contains the
* string being defined, the string to substitute
* for the defined string, and a link to the next
* def structure. The defined string is a sequence
* of characters not containing any white space
* (i.e. NO SPACEs or TABs). The substitution string
* may contain SPACES and/or TABs.
*/
struct def
{
struct def *d_dp; /* link to next define */
char *d_id; /* defined string */
char *d_define; /* string to substitute for defined string */
int d_dflag; /* (1) .defined / (0) .undefined */
};
but as far as I can tell, that structure is not used anywhere.
Upvotes: 2