> I want to know how address of SFR register can be passed as parameter to
> a function.
Assuming that you target an 8051 system: you can't address SFR registers via
"pointer". The processor distinguishes SFR from IDATA by the access type
inherent in the opcode. SFR can only be accessed directly, IDATA (range 0x80
to 0xFF) only through a pointer.
If you badly need to access SFR through a address parameter, you need
something like:
__sfr __at (0x80) SFR_80;
__sfr __at (0x81) SFR_81;
__sfr __at (0x82) SFR_82;
/*...*/
__sfr __at (0xFF) SFR_FF;
unsigned char get_sfr(unsigned char address) {
switch (address) {
case 0x80:
return SFR_80;
case 0x81:
return SFR_81;
case 0x82:
return SFR_82;
/*...*/
case 0xFF:
return SFR_FF;
}
}
HTH, Bodo
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sdcc-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sdcc-user