I'm using a Philips P89C662 that provides In-system Application Programming (IAP) with have an entry address at 0xFF00. I am trying to read proram boot vector information. I an not sure how to refer to registers R0 & R1. R0 register is set to FOSC and R1 is set to 06 for boot vector. All other registers are defined in the reg66x.h file. Registers AUXR1, DPL, DPH are alredy defined. Only R1 & R2 are not defined. typedef void (*pgm_mtp_ptr)(int); pgm_mtp_ptr iap_call = (pgm_mtp_ptr) 0xFFF0; unsigned char vec; AUXR1= 0x20; /* set the ENBOOT bit */ R0 = 18; /* FOSC */ R1 = 0x7; /* Read Misc Function */ DPH = 0x0; DPL = 0x2; /* specify boot vector */ vec = 0; /* init vec to zero */ vec = iap_call(); /* call PGM_MTP @0xfff0 */ I am getting error C2002: 'R0' and 'R1' : as undefined variables. sfr R0 = 0x0; sfr R1 = 0x1; Cannot define using sfr as 0 & 1 as compiler complains about invalid base addresss. Can some one point to me as to how to set the various IAP commands in Register R1 ????? Thanks, Venkat
"That begs a question: why?" Absolutely! Fiddling about with processor registers (as opposed to peripheral registers) is almost always best done in assembler. Remember, the 'C' compiler is free to use the processor registers in whatever way it sees fit - so, just because you somehow manage to force your value into R0 there is no guarantee that the same value will still be there by the next 'C' statement!
Take a look to Knowledgebase article C51: INTERFACE FOR IAP FUNCTIONS ON PHILIPS DEVICES at http://www.keil.com/support/docs/2045.htm. Maybe this small interface routine helps you to solve your problem.