From: Skybuck Flying on
Hello,

"If Skybuck can do it then so can you !"

I wonder why high level languages like Delphi and FreePascal do not have ror
and rol support ?

Which processors targetted by FreePascal do not have ror and rol support me
wonders ?

I suspect I need these routines to be able to easily, flawlessly, and
branchlessly/fastly implement a WriteLongwordBits routine.

See other thread about issue's with WriteLongWordBits.

So today I present to you a Skybuck-Solution =D

I shall now try to use this Skybuck-Solution to implement further Solutions
! =D

Stay tuned ! ;) =D

// *** Begin of Code ***

program Project1;

{$APPTYPE CONSOLE}

{

Skybuck presents RotateLeft and RotateRight routines.

Version 0.01 created on 5 may 2008 by Skybuck Flying

"If Skybuck can do it, then so can you !" ;) =D

}

uses
SysUtils;

// rotate left routines
function RotateLeft8( Value : byte; Bits : longword ) : byte;
asm
mov cl, dl
rol al, cl
end;

function RotateLeft16( Value : word; Bits : longword ) : word;
asm
mov cl, dl
rol ax, cl
end;

function RotateLeft32( Value : longword; Bits : longword ) : longword;
asm
mov cl, dl
rol eax, cl
end;

// rotate right routines
function RotateRight8( Value : byte; Bits : longword ) : byte;
asm
mov cl, dl
ror al, cl
end;

function RotateRight16( Value : word; Bits : longword ) : word;
asm
mov cl, dl
ror ax, cl
end;

function RotateRight32( Value : longword; Bits : longword ) : longword;
asm
mov cl, dl
ror eax, cl
end;

procedure Main;
begin
writeln('program started');

writeln( RotateLeft32(2147483648, 2) );
writeln( RotateRight8(128, 2) );

writeln('program stopped');
end;

begin
try
Main;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
readln;
end.

// *** End of Code ***

Bye,
Skybuck.