On Wed, 2011-08-10 at 20:55 +0200, Bodo Wenzel wrote: > Hi Mike, > > > I am trying to access a sfr with a pointer (mcs51 P2, P2MDOUT, ...) > It's not a question of the compiler. It is not possible because of the > opcodes of the MCS51. There is no machine instruction to access SFR > through a pointer. Ok Thanks. I've start down the switch statement path. I was just hoping there was a more elegant solution. > > The only solution I once found was to write a function that takes the > address as argument. In the implementation is a huge switch which does > the actual access, like this: > > __sfr __at (0x80) SFR_80; > __sfr __at (0x81) SFR_81; > /* ... be hard-working ... */ > __sfr __at (0xFF) SFR_FF; > > unsigned char readSFR(unsigned char address) { > switch (address) { > case 0x80: > return SFR_80; > case 0x81: > return SFR_81; > /* ... be hard-working ... */ > case 0xFF: > return SFR_FF; > default: > return 0; /* or read the internal RAM */ > } > } > > It's a lot of source code but the object code is quite small. To write > to an arbitrary SFR a similar second function can be written. > > HTH > Bodo > > > > ------------------------------------------------------------------------------ > 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 > Sdcc-user@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/sdcc-user
------------------------------------------------------------------------------ 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 Sdcc-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sdcc-user