From: ellman AT xs4all DOT nl () Newsgroups: comp.os.msdos.djgpp Subject: Re: big endian class Date: 31 May 1997 14:05:30 GMT Organization: XS4ALL Message-ID: <5mpb7b$3nm$1@news0.xs4all.nl> References: <338F1A19 DOT 474E AT blackmagic DOT tait DOT co DOT nz> NNTP-Posting-Host: xs1.xs4all.nl Lines: 33 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk In article <338F1A19 DOT 474E AT blackmagic DOT tait DOT co DOT nz>, Bill Currie wrote: >If anyone can figure a better way of byte swapping longs (without useing >bswap), preferably in c, please let me know as gcc can't optimise >swapBytes(long) or swapBytes(ulong) when called with constants (due to >the assembly code). void swapbytes(long *the_variable) { register char b0,b1,b2,b3; b0 = *(((char *)(the_variable))); b1 = *(((char *)(the_variable))+1); b2 = *(((char *)(the_variable))+2); b3 = *(((char *)(the_bariable))+3); *(((char *)(the_variable))) = b3; *(((char *)(the_variable))+1) = b2; *(((char *)(the_variable))+2) = b1; *(((char *)(the_variable))+3) = b0; } If you have some means of detecting wether your program will be comipled for a 486, use inline assembly with the bswap instruction. AE. Andrei Ellman -- URL: http://www.xs4all.nl/~ellman/ae-a -- ae1 AT york DOT ac DOT uk "All I wanna do is have some fun :-) || ae-a AT minster DOT york DOT ac DOT uk I've got the feeling I'm not the only one" || mailto:ellman AT xs4all DOT nl -- Sheryl Crow :-) || It's what you make of it.