From: "Sven Pran" Subject: Re: How to reverse the bits in a integer? Date: 15 Mar 2000 00:00:00 GMT Message-ID: <8anq1f$p41$1@netox20.alcatel.no> References: <8al9dn$oj2$1@newton.pacific.net.sg> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Alcanet International SC - Newshub - http://www.alcanet.no/ X-MSMail-Priority: Normal Newsgroups: comp.lang.pascal.delphi.misc The following routine does the job (and is fast too): function Reversed(source: longint): longint; asm mov EDX,EAX mov ECX,32 @@loop: RCL EDX,1 RCR EAX,1 LOOP @@LOOP end; It left-shifts each bit from EDX into the carry flag and then right-shifts the carry flag into EAX a total of 32 times (controlled by ECX). hth regards Sven Tan Tze Yong wrote in message news:8al9dn$oj2$1@newton.pacific.net.sg... > Dear fellow Delphi programmers, > Is it possible to reverse the bits in a integer, i.e. move the most > significant bit to the front? Any help will be appreciated.