Search code examples
assemblyz80sdcc

Can't get .define working with sdasz80 (sdcc assembler)


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?


Solution

  • 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.