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
I thought the MOV instruction only worked with constants and registers. Jon
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)
Actually I defined the sfr like this... #define GPT12E_T5 (*((uword volatile *) 0xFE46)) Is there any problem in that --Sunil
Yes, there is a problem: the inline assembler cannot deal with 'C' expressions such as '*((unsigned int *) 0xFE46)' etc. It can handle identifers, numbers and assembly language operators only.
Thanks Peter.... --Sunil