From: Bo-Yi L. <bl...@ik...> - 2001-03-18 09:00:56
|
Ok, Thanks to all for the replies. I was using the correct forward declaration. Sandeep thinks this needs fixing. Maybe he forgot. I'll wait for the next release because I cannot get CVS to run on my workstation. Bo ----- Original Message ----- From: "Johan Knol" <joh...@id...> To: <sdc...@li...> Sent: Saturday, March 17, 2001 8:10 AM Subject: Re: [Sdcc-user] movx gets "optimized" out of loop! > > Hi, > > > > I'm trying to write a polling routine that polls for a low status bit at > a > > specific device register address. Here's a code snippet: > > ------------------------------------------------------------------- > > #typedef unsigned char BYTE > > void PollLo(volatile xdata BYTE * addr, BYTE bitmask) { > > BYTE in; > > > > do { > > in = *addr; > > } while (in & bitmask); > > } > . > . > > ------------------------------------------------------------------- > > The declaration says *addr is a pointer to a volatile BYTE. But if I do > > this, the movx (in=*addr) gets placed outside the do loop. The only way > I > > can get the movx inside the do loop is to use > > (xdata BYTE * volatile addr) instead. But in effect I'm saying the > pointer > > itself is volatile, which is not what really I want because I do not need > > the pointer to be dereferenced inside the loop. Does anybody know how to > > get the compiler to do this right? > > It was a bug in the compiler that is now fixed. > > > Any why does it keep saving dptr to > > r2/r3 and back again? dptr is already set by the caller routine so the > > exercise seems pointless. > > Because addr is assigned to registers r2/r3. Dp registers are used as > temporaries. But you are right, this should be optimized. > > Johan > > > > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > http://lists.sourceforge.net/lists/listinfo/sdcc-user > |