Which compiler are you using? Try this instead: ptr = (unsigned char *)(((unsigned long)ptr) & 0xFFC0); that's because when dealing with pointers, the + operator increments by the size of the object being pointed to. unsigned long ptr; ptr++; adds 4 to the value of pointer. casting the pointer to a number allows you to do your binary manipulation, then cast it back to a pointer. For you alignment question, check this out: http://gcc.gnu.org/onlinedocs/gcc/Type-Attributes.html -- Sean At 19:06 2/6/2006, you wrote: >Hello, > >I have been doing assembly so long, that I am having trouble with >my C program. > >I have records of 64 bytes in length, and the start of the record area >must start on an even 0x0100 boundary in ram. > >In assembly, doing tests on the pointer for being in the middle of a >record, or to jump to the next record is a piece of cake. > >assuming: >unsigned char data[2048]; is aligned on an even boundary >unsigned char *ptr; >#define RECORD_SIZE 64 >#define INCREMENT_MASK 0xffc0 >#define LINE_MASK 0x3f //record_size -1 > > ptr = data; > .... >the compiler hates: > ptr &= INCREMENT_MASK; // in case we are in the middle of a rec >but tolerates this: > ptr += RECORD_SIZE; //jump to the start of the next record > >since the ram area is 64k, i would think this would work. > >TIA > >Glen > > > > > >SPONSORED LINKS ><http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=mfaAujKZXA2Z_vxre9sGnQ>Microcontrollers ><http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=9jjd2D3GOLIESVQssLmLsA>Microprocessor ><http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=OMnZuqMZX95mgutt4B-tDw>Intel >microprocessors ><http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=Malspbd0T4Rq3M4Q0nHrfw>Pic >microcontrollers > > >---------- >YAHOO! GROUPS LINKS > > * Visit your group "<http://groups.yahoo.com/group/lpc2000>lpc2000" > on the web. > * > * To unsubscribe from this group, send an email to: > * > <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>lpc2000-unsubscribe@yahoogroups.com > > * > * Your use of Yahoo! Groups is subject to the > <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service. > > >----------
Message
Re: [lpc2000] embarrassing question
2006-02-07 by Sean
Attachments
- No local attachments were found for this message.