Menu

#21 assembler support

Moritz_2_0_1
closed
None
5
2021-01-01
2020-12-28
No

Hello Eckard,

do you have an idea how to pass inline assembler through the parser?
Code like this

        __asm volatile (" MRC    p0, #0, %[result], c7, c1 "  : [result] "=r" (valCR7)  : );
        valCR7 = (valCR7 & 0xFFFFFF00U) | (SMK_FLASH_USAGE_UNBLOCK_NOT_REQUESTED);
        __asm volatile (" MCR    p0, #0, %[input], c7, c1 "  : : [input] "r" (valCR7) );

fails. I tried to enhance the UserGrammar.a2x by adding

userAttribute = 
   ("__" >> "VARIABLE_PREPROCESSOR")
 | ("__" >> "FUNC_RET_PREPROCESSOR")
 | ("__" >> "FUNC_PARAM_PREPROCESSOR")
 | ("__" >> "asm")
 ;

but without success
BR
Wasili

Discussion

  • Eckard Klotz

    Eckard Klotz - 2020-12-29

    Hello Wasili.

    The coding of inline-assembler is very compiler specific.

    • Some are doing it with a function like syntax others with pragma directives.
    • I never saw your approach before.

    However this is something that could not be supported by a standard solution.
    Thus I would not accept this as a bug.

    Your idea to solve this with the user-grammar is the only possible solution. But we have to introduce a new rule (perhaps some more) to solve this problem.

    Just extending the user-attribute will not help.

    1. The user Attribute will not be called inside a source where you place your assembler commands.
    2. The content of the brackets with the : as splitter is not described in a syntax-rule.

    Please give me some time to set-up a basic solution. Once I have something, I will create a new topic in the development forum to continue this discussion.

    Have a happy new year, take care about you and stay healthy,
    Eckard.

     

    Last edit: Eckard Klotz 2020-12-29
  • Eckard Klotz

    Eckard Klotz - 2020-12-30

    Hello Wasili.

    As already mentioned above I have set up a new topic User Extension of the C/Cpp Grammar for Inline-Assembler in the development discussion .

    Here I posted a first trial to solve your issue regarding your inline assembler.

    • Please use from now this development forum topic to discuss this issue.
    • Note: Since I'm not really familiar with inline-assembler, the current user-grammar syntax-rules are sufficient to parse your small example but may struggle by other inline-assembler lines used in your real code.
    • Pleases use the development forum topic also to discuss those issues.

    I wish you a happy new year and please stay healthy,
    Eckard.

     

    Last edit: Eckard Klotz 2020-12-30
  • Eckard Klotz

    Eckard Klotz - 2021-01-01
    • status: open --> closed
     

Log in to post a comment.