This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Ax51 attempt to define an already defined label

I'm trying to use the ax51 standard macro assembler to find a way to determine if a symbol or label is already defined. Something like the following pseudo code:

if label "table_abc" is defined, do nothing, else do the following:
table_abc: DB 1 DB 2 DB 3
endif

I somehow thought the following could work but alas it does not:
IF NOT :DEF:table_abc
table_abc: DB 1 DB 2 DB 3
ENDIF

-> LABEL NOT PERMITTED, SYNTAX ERROR

My code is 100 percent assembler code so I try to not use the C preprocessor. But if there is no other way, a C preprocessor code example would help as well.

EFM8BB31, Silicon Labs Simplicity Studio v3, Keil 8051 v9.53 debug

Parents Reply Children
  • No, that construct doesn't "work", because it does not do what you originally said you wanted to do. It does not detect whether a label is defined ... it checks whether a macro is defined. That's really quite a different thing.

    Nor does it fulfill the underlying secret goal you revealed later, about taking care of things the user might have forgotten to do. This construct will still fail just as badly as an unprotected label definition, because a user who didn't know they were supposed to define that label will be equally uninformed about the need to define some macro, on top of that.

  • You are right, this solution won't help for an uninformed user. Thanks.