Microchip Technology SW006022-2N 数据表

下载
页码 338
MPLAB
®
 XC16 C Compiler User’s Guide
DS52071B-page 206
 2012 Microchip Technology Inc.
EXAMPLE 16-3: 
SPECIFY A VARIABLE TO BE PLACED IN PROGRAM 
MEMORY 
EXAMPLE 16-4: 
LOCATE THE FUNCTION PRINTSTRING AT ADDRESS 
0X8000
 IN PROGRAM MEMORY
EXAMPLE 16-5: 
COMPILER AUTOMATICALLY SAVES AND RESTORES THE 
VARIABLES VAR1 AND VAR2
PICC18
const char my_const_array[10] =  {0,1,2,3,4,5,6,7,8,9};
C18
#pragma romdata const_table
const rom char my_const_array[10] =
  {0,1,2,3,4,5,6,7,8,9};
XC16
const
 or
_ _attribute_ _((space(auto_psv)))
  char my_const_array[10] = {0,1,2,3,4,5,6,7,8,9};
PICC18
int PrintString(const char *s)@ 0x8000 {...}
C18
#pragma code myTextSection=0x8000;
int PrintString(const char *s){...}
XC16
int _ _attribute_ _((address(0x8000))) PrintString
  (const char *s) {...}
PICC18
No equivalent
C18
#pragma interrupt isr0 save=var1, var2
   void isr0(void)
   {
   /* perform interrupt function here */
   }
XC16
void _ _attribute_ _((_ _interrupt_ _(_ _save_ _(var1,var2))))
  isr0(void) 
  {
  /* perform interrupt function here */
  }