Keil Logo

A51: Locate Syntax Erros 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: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.