Page 1 of 1

error 876 syntax error for using movwf inline asm for PIC16f

PostPosted: Sat Jan 06, 2024 11:07 am
by wolfrose
Hi,

I want to port a code from PIC18f46k22 to PIC16f877A for education purposes, I know PIC16f877A is an old chip but the warehouse has PIC16f877A as the best chips available. And it's more than enough for diploma students. For me I personally have PIC18f46k22 as my go-to PIC development set.

So, when I ported the code, everything works ok, but this inline asm didn't work:
Code: Select all
    asm("movwf   ?_millis+0,a        ");


In this function:

Code: Select all
uint32_t millis(void)
{
    asm("bcf     INTCON,"___mkstr(_INTCON_GIE_POSN));
    asm("movf   __tmr1_ms+0,w        ");
    asm("movwf   ?_millis+0,a        ");
//    asm("movf   __tmr1_ms+1,w        ");
//    asm("movwf   ?_millis+1,a        ");
//    asm("movf   __tmr1_ms+2,w        ");
//    asm("movwf   ?_millis+2,a        ");
//    asm("movf   __tmr1_ms+3,w        ");
//    asm("movwf   ?_millis+3,a        ");
    asm("retfie                      ");  // return millis with GIEH = 1;
    return 0;
}


What to do ?

Re: error 876 syntax error for using movwf inline asm for PI

PostPosted: Sat Jan 06, 2024 9:58 pm
by wolfrose
OK I removed the `,a` and the code compiled successfully.

Re: error 876 syntax error for using movwf inline asm for PI

PostPosted: Sat Jan 13, 2024 7:38 am
by ric
Indeed, PIC16F chips don't have an "Access Bank", so don't use that suffix.