Mixing ASM and C.Error:C18107: Illegal Operands

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mixing ASM and C.Error:C18107: Illegal Operands

1,659 Views
FordFairlaneBen
Contributor I
Hi:
I´m mixing assembler and C code. The assembler code is in the next macro generated by Processor Expert.
 
/*lint -restore */
#define SaveStatusReg() \
/*lint -save -e505 -e522 -esym(960,54) Disable MISRA rule (53,54) checking. */\
 { asm PSHA; asm TPA; asm SEI; asm STA CCR_reg; asm PULA; } /* This macro is used by Processor Expert. It saves CCR register and disable global interrupts. */ \
/*lint -restore */
 
The code in C is the next:
 
byte NonDestructiveUnsecureWrite(word src, word dst, word size)
{
word x;                                /* Tmp. var. */
FnBurstProgCmdInRamStruct FnBurstProgCmdInRam=*(FnBurstProgCmdInRamStruct *)(FnBurstProgCmdInRam_); /* Copy function into the stack */
 if(dst < 0x8000) {                   /* Check addres */
   return ERR_RANGE;                  /* Address is out of FLASH memory */
 }
 if((size > 0x8000) || (dst+size-1 < 0x8000)) { /* Check block size and last addres of the block */
   return ERR_RANGE;                  /* Block is out of FLASH memory */
 }
 if(!FSTAT_FCCF) {                    /* Is previous command completed ? */
   return ERR_BUSY;                   /* If no then error */
 }
 SaveStatusReg();                     /* Save status information and disable interrupts(if enabled) */
 FSTAT=0x00;                          /* Init. flash engin */
 if(FSTAT & BM_FLASH_ERR_MASK) {      /* Protection violation or access error? */
   FSTAT = BM_FLASH_ERR_MASK;         /* Clear FPVIOL & FACERR flag */
 }
 ((pFnBurstProgCmdInRam)&FnBurstProgCmdInRam)(src,dst,size); /* Call code in ram */
 if(FSTAT & BM_FLASH_ERR_MASK) {      /* Error detected? */
   RestoreStatusReg();                /* Yes, restore status information and interrupt state */
   if(FSTAT_FPVIOL) {                 /* Protect violation? */
     return ERR_PROTECT;              /* Return error code ERR_PROTECT */
   } else {
     return ERR_NOTAVAIL;             /* Return error code ERR_NOTAVAIL */
   }
 }
 RestoreStatusReg();                  /* Restore status information and interrupt state */
 for(x=0x00;x<size;x++) {             /* Compare src. and written block */
   if(((byte*)src)[x] != ((byte*)dst)[x]) { /* Compare source byte and written byte */
     return ERR_VALUE;                /* Source value is different from dest. value, return error */
   }
 }
 return ERR_OK;
}
 
When I compiled I get two errors:
Illegal Operands and Label not set. I have compared it with other macros generated by processor Expert and I can find any difference. Why I am getting these errors?
Thanks.
Best Regards.
Labels (1)
0 Kudos
2 Replies

417 Views
rocco
Senior Contributor II
Hi, Ford:

Just a guess:
Do you have "CCR_reg" defined in ram somewhere?
0 Kudos

417 Views
FordFairlaneBen
Contributor I
Hi:
Ok, that´s the point. Now is working yet.
Thanks.
0 Kudos