From: Robert Lee Subject: Re: Converting SUN number to Intel Date: 25 Aug 1999 00:00:00 GMT Message-ID: <37C3DD91.4E6B5D6D@nwu.edu> Content-Transfer-Encoding: 7bit References: <7q0f3d$lf72@forums.borland.com> <37C3DC54.6A5F62D6@access.ch> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Newsgroups: borland.public.delphi.objectpascal Rene Tschaggelar wrote: > > for storing the numbers, there is the big endian/little endian issue. I suspected that this was the issue but I wasn't sure. The underlying tidbit you need is an assembler instruction called 'bswap' that reverses the bytes in a 32bit quantity. Here's a collection of Swap routines. You'll note that many are the same except for the typing of the params/result. Also I assume that you pass the backwards version essentially as untyped DWords. type TData8=double; function Swap2(a:cardinal):word; asm bswap eax shr eax,16 end; function Swap4(a:cardinal):cardinal; asm bswap eax end; function Swap4Signed(a:cardinal):longint; asm bswap eax end; procedure SwapDoubleTo8(const a:double; var b:TData8); asm mov edx,dword ptr[a] mov ecx,dword ptr[a+4] bswap edx bswap ecx mov dword ptr [eax],ecx mov dword ptr [eax+4],edx end; function Swap8ToDouble(var a:TData8):double; var hold:double; asm mov edx,dword ptr[eax] mov ecx,dword ptr[eax+4] bswap edx bswap ecx mov dword ptr [hold],ecx mov dword ptr [hold+4],edx fld hold; end; -- Bob Lee High Performance Delphi - http://www.econos.com/optimize/