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

Extended Inline Assembly

Hi,

I am using extended inline assembly functionality in Keil with keyword __asm.

The compiler is giving error!!!!

For the following code,
__asm { mov GPT12E_T5,#0x3CB0 }

The following error is coming.....

GPT2.C(195): error C195: inline-asm: invalid expression token
GPT2.C(195): error C195: inline-asm: missing ')'
GPT2.C(195): error C195: inline-asm: Invalid instruction operand(s)

My question is, in order to use extended inline assembly any seetings has to be done in the Keil. Or is anything wrong with the code.

Regards
Sunil

Parents
  • Looks like you forgot to include the sfr declarations which causes 'GPT12E_T5' being undefined. Otherwise the examples compiles fine here:

    C166 COMPILER V5.20a, COMPILATION OF MODULE X
    OBJECT MODULE PLACED IN x.OBJ
    COMPILER INVOKED BY: C:\keil\c166\bin\c166.exe x.c CODE MOD167
    
     stmt lvl     source
    
        1
        2         #include <\keil\c166\inc\xc16X.h>
        3
        4         //sfr GPT12E_T5 = 0xFF46;
        5
        6         void Test (void)  {
        7  1        __asm  { mov GPT12E_T5,#0x3CB0 }
        8  1      }
    
    
                 ; FUNCTION Test (BEGIN  RMASK = @0x8000)
                                               ; SOURCE LINE # 6
                                               ; SOURCE LINE # 7
    0000 E623B03C      mov GPT12E_T5,#0x3CB0
                                               ; SOURCE LINE # 8
    0004 CB00          RET
                 ; FUNCTION Test (END    RMASK = @0x8000)
    
    C166 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
    

Reply
  • Looks like you forgot to include the sfr declarations which causes 'GPT12E_T5' being undefined. Otherwise the examples compiles fine here:

    C166 COMPILER V5.20a, COMPILATION OF MODULE X
    OBJECT MODULE PLACED IN x.OBJ
    COMPILER INVOKED BY: C:\keil\c166\bin\c166.exe x.c CODE MOD167
    
     stmt lvl     source
    
        1
        2         #include <\keil\c166\inc\xc16X.h>
        3
        4         //sfr GPT12E_T5 = 0xFF46;
        5
        6         void Test (void)  {
        7  1        __asm  { mov GPT12E_T5,#0x3CB0 }
        8  1      }
    
    
                 ; FUNCTION Test (BEGIN  RMASK = @0x8000)
                                               ; SOURCE LINE # 6
                                               ; SOURCE LINE # 7
    0000 E623B03C      mov GPT12E_T5,#0x3CB0
                                               ; SOURCE LINE # 8
    0004 CB00          RET
                 ; FUNCTION Test (END    RMASK = @0x8000)
    
    C166 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)
    

Children