// gcc must use -fPIC -mno-abicalls

#define DEVID ((*(volatile unsigned int *)0xBF80F220) & 0xfffffff)
#define PIC32MX170F256B_DEVID  0x06610053
#define PIC32MX270F256B_DEVID  0x06600053
#define PIC32MX170F256D_DEVID  0x0661A053
#define PIC32MX270F256D_DEVID  0x0660A053
#define PIC32MX470F512H_DEVID  0x0580A053
#define PIC32MX470F512L_DEVID  0x0580B053

// function to figure out what type of CPU MMBasic is running on
long long int main(void) {
    unsigned int i = 0;
    if(DEVID == PIC32MX170F256B_DEVID) i = 1;
    if(DEVID == PIC32MX270F256B_DEVID) i = 2;
    if(DEVID == PIC32MX170F256D_DEVID) i = 3;
    if(DEVID == PIC32MX270F256D_DEVID) i = 4;
    if(DEVID == PIC32MX470F512H_DEVID) i = 5;
    if(DEVID == PIC32MX470F512L_DEVID) i = 6;
    return i;
}
