Keil™, An ARM® Company

Technical Support

A51: LOCATE SYNTAX ERRORS WHEN USING MACROS


Information in this article applies to:

  • A51 All Versions
  • AX51 All Versions
  • A251 All Versions

QUESTION

I wrote the following small assembler program using macros:

ISAIN   MACRO   IO_ADDR
        MOV     ADDRPORT,#IO_ADDR
        MOVX    A,@R0
        ENDM

        ISAIN   0x1f

        END

These syntax errors were generated. What is wrong with my code?

                       1
                       2     ISAIN   MACRO   IO_ADDR
                       3             MOV     ADDRPORT,#IO_ADDR
                       4             MOVX    A,@R0
                       5             ENDM
                       6
                       7             ISAIN   0x1f
*** _________________________________________^
*** ERROR #A45 IN 8 (x.a51, LINE 7): UNDEFINED SYMBOL (PASS-2)
                      10
                      11             END

ANSWER

The syntax problem is within the macro you have written. You should include the macros in the listing. This is enabled under µVision with Project - Options for Target - Listing - Assembler Listing - Assembler Listings - Macros - All Expansions or from the command line with the GEN assembler directive.

Then you can see the real syntax problem:

                       7             ISAIN   0x1f
0000                   8+1           MOV     ADDRPORT,#0x1f
*** _________________________________________^
*** ERROR #A45 IN 8 (x.a51, LINE 7): UNDEFINED SYMBOL (PASS-2)
0003 E2                9+1           MOVX    A,@R0
                      10

In your code, the symbol ADDRPORT is not defined, which caused the syntax problem.

SEE ALSO

Last Reviewed: Tuesday, April 27, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure