#276 please add asm() pseudo function as alternate

closed
None
5
2012-03-18
2009-07-01
dfulab
No

Is it possible to add the asm() as an alternate to _asm _endasm?
The reason why I am asking is that _asm and _endasm seems to be doing a lot of unnecessary processing that so far causes bugs in my embedded assembly code. I would like to see one that treats the embedded as a string and simply paste it into the assembly file without any processing. Since it doesn't make sense to alter the behavior of existing feature, this would be an alternative.

Bugs I have caught so far for Z80 version:
- assembly comments contains ! causes internal error (resolved)
- ex af,af' - that extra ' is part of a valid operand, but causes an error because the compiler thinks it is an unclosed ' ' quote. I had to use a .db with the right values to trick the compiler into putting the right code.
- multi-line #define macro issues all lumped into the same line. If you are not careful, this can cause serious issues. A simple ; comment can turn every assembly code after it into comments.

The following is taken from ez80 port from freertos project. This makes the assembly listing easier to read instead of a clump of text all squeezed into a single line. Also funny stuff like the ex af,af' won't cause grief and eliminates any potential compiler induced bug cause by its own processing.

#define portSAVE_CONTEXT() \ asm ( "xref _pxCurrentTCB \n\t" \ "di \n\t" \ "push af \n\t" \ "in0 a, (62h) \n\t" \ "push bc \n\t" \ "push de \n\t" \ "push hl \n\t" \ "push iy \n\t" \ "ex af, af' \n\t" \ "exx \n\t" \ "push af \n\t" \ "push bc \n\t" \ "push de \n\t" \ "push hl \n\t" \ "ld ix, 0 \n\t" \ "add ix, sp \n\t" \ "ld hl, (_pxCurrentTCB) \n\t" \ "ld (hl), ix \n\t" \ );

Discussion

  • b-s-a

    b-s-a - 2012-03-11

    Moreother, this suggestion provides way to assign values to registers before inline assembler execution (for example, as in gcc), registers to output value after execution and information about used registers in the assembler block. Currently, I do not see any way to do that.

     
  • Borut Ražem

    Borut Ražem - 2012-03-18

    asm () and __asm__ () implemented in svn revision #7462.

    Borut

     
  • Borut Ražem

    Borut Ražem - 2012-03-18
    • assigned_to: nobody --> borutr
    • status: open --> closed
     
  • Philipp Klaus Krause

    Well, even though there noe is __asm__() (and asm(), which I hipe will go away again), I think that the '-issue with the old approach should be fixed, if it still exists. We manage to ignore a stray ' in comments or #if 0, so it should be possible for __asm, __endasm, too.

    Philipp

     
  • Borut Ražem

    Borut Ražem - 2012-03-19

    #pragma preproc_asm -
    solves the '-issue.

    Borut

     
  • Borut Ražem

    Borut Ražem - 2012-03-19

    asm() removed in svn revision #7471.

    Borut

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks