home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_02_05
/
2n05021a
< prev
next >
Wrap
Text File
|
1991-03-27
|
738b
|
37 lines
program byteFlip;
var
theTime: longint; (* keep time in 60ths of a second *)
value: longint;
i: integer;
(* Here is a crude high-level language function to change
byte order *)
(* no effort at optimization has been taken *)
function FlipOrder (n: longint): longint;
var
result: longint;
begin
FlipOrder := BSL(BAND(n, $000000FF), 24) + BAND(BSL(n, 8),
$00FF0000) +
BitAnd(BSR(n, 8), $0000FF00) + BitAnd(BSR(n, 24), $000000FF);
end;
begin
ShowText;
value := $01020304;
theTime := TickCount;
for i := 0 to 9999 do
begin
value := FlipOrder(value);
end;
theTime := TickCount - theTime;
writeln('Time per flip =', (theTime / 60.0) / 10000.0 : 12 : 6);
readln;
end.