On Thu, 2007-02-08 at 23:58 +0100, Luit van Drongelen wrote:
> I was wondering if I could assign the value of a short int (0x0FFF for
> example) to two config bytes (like the PDC0L and PDC0H bytes) in a
> single line, or any other simple way...

This is difficult, as SDCC is inherently little-endian, whereas PDC0L
and PDC0H are stored as big-endian, i.e. the high byte resides at the
lower address.
You could use a construct like

#define U(x)        ((unsigned int)(x))
#define TO_BIGE(x)  ((U(x) << 8) | (U(x) >> 8))

void foo(unsigned int val) {
  *(__data unsigned int *)(&PDC0H) = TO_BIGE(val);
  // or, if &PDC0H does not work
  *(__data unsigned int *)(0xF78) = TO_BIGE(val);
}

Not sure, though, that SFR like to be accessed indirectly...

Good luck,
Raphael



-------------------------------------------------------------------------
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

Reply via email to