From: Martin Harvey Subject: Re: Reading Big Endian byte order Date: 20 Jul 1999 00:00:00 GMT Message-ID: <3794C663.29A80CCD@aziraphale.demon.co.uk> Content-Transfer-Encoding: 7bit X-NNTP-Posting-Host: aziraphale.demon.co.uk:194.222.242.160 References: <7mvd1i$cjv$1@zmaj.etf.bg.ac.yu> <932416027.5085.1.nnrp-13.c2de6535@news.demon.co.uk> X-Accept-Language: en X-Server-Date: 20 Jul 1999 18:58:01 GMT Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@demon.net X-Trace: news.demon.co.uk 932508997 nnrp-09:13958 NO-IDENT aziraphale.demon.co.uk:194.222.242.160 Organization: Mark's linux box Mime-Version: 1.0 Newsgroups: comp.lang.pascal.delphi.misc Jeremy Collins wrote: > > > IIRC the ntohl function does this. > Yes on Wintel, however, to assume that it'll do that on all platforms that Delphi might run on might be a bit optimistic. Any of the follwing will work: function wordswap(in:word):word; asm mov in,ax rol ax,8; end; function dwordswap(in:cardinal):cardinal; asm mov in,eax rol ax,8 rol eax,16 rol ax,8 end; endless permutations of the above are possible, in both pascal and asm. MH. -- Martin Harvey. martin@aziraphale.demon.co.uk mch24@harvey27.demon.co.uk http://www.harvey27.demon.co.uk/mch24/