On Sun, 12 Feb 2012, Jeff Epler wrote: > Date: Sun, 12 Feb 2012 21:31:36 -0600 > From: Jeff Epler <[email protected]> > Reply-To: EMC developers <[email protected]> > To: EMC developers <[email protected]> > Subject: Re: [Emc-developers] SSERIAL bug with stream type data with > datawidth=32 > > On Sun, Feb 12, 2012 at 06:29:49PM -0800, Peter C. Wallace wrote: >> 147 case 0x06: // byte stream >> 148 buff = *pin->u32_pin & ((1 << conf->DataLength) - 1); >> 149 break; > > Hm, perhaps this is the correct replacement: > buff = *pin->u32_pin & (0xffffffffu >> (32 - conf->DataLength)); > > I wrote the following program to verify the equivalence of this and the > original-with-special-case for arguments of 1..32 inclusive: > > #include <assert.h> > #include <stdint.h> > > uint32_t f1(int n) { > if(n == 32) return 0xffffffffu; > return (1 << n) - 1; > } > > uint32_t f2(int n) { > return 0xffffffffu >> (32 - n); > } > > int main() { > int i; > for(i=1; i<32; i++) { > assert(f1(i) == f2(i)); > } > return 0; > } > > this moves the "shift 32 bits" case to correspond to a DataLength of 0, which > probably represents misconfiguration. > > Jeff
Thanks! Thats a lot more elegant than what I did... > > ------------------------------------------------------------------------------ > Try before you buy = See our experts in action! > The most comprehensive online learning library for Microsoft developers > is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, > Metro Style Apps, more. Free future releases when you subscribe now! > http://p.sf.net/sfu/learndevnow-dev2 > _______________________________________________ > Emc-developers mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/emc-developers > Peter Wallace Mesa Electronics (\__/) (='.'=) This is Bunny. Copy and paste bunny into your (")_(") signature to help him gain world domination. ------------------------------------------------------------------------------ Try before you buy = See our experts in action! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-dev2 _______________________________________________ Emc-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-developers
