> I am trying to access a sfr with a pointer (mcs51 P2, P2MDOUT, ...)
I use the following function for reading of arbitrary SFR:
#define sfr1(A) case A&0x7F: __asm mov _SFR,A __endasm; break;
#define sfr16(A) sfr1(A) sfr1(A+1) sfr1(A+2) sfr1(A+3) sfr1(A+4)
sfr1(A+5) sfr1(A+6) sfr1(A+7) \
sfr1(A+8) sfr1(A+9) sfr1(A+10) sfr1(A+11) sfr1(A+12)
sfr1(A+13) sfr1(A+14) sfr1(A+15)
unsigned char SFR;
void getSFR(unsigned char addr)
{ switch (addr&0x7F)
{ sfr16(0x80) sfr16(0x90) sfr16(0xA0) sfr16(0xB0) sfr16(0xC0) sfr16(0xD0)
sfr16(0xE0) sfr16(0xF0) } }
Function returns value of SFR in global variable SFR.
Arnost
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user