[fpc-devel] ROL/ROR with Carry
Florian Klämpfl
florian at freepascal.org
Mon Jan 11 22:04:55 CET 2021
Am 11.01.21 um 19:10 schrieb Sven Barth via fpc-devel:
> Hello together!
>
> Considering that jamie philbrook has given up on his feature request (
> https://bugs.freepascal.org/view.php?id=38341 ) rather quickly and that
> it had been my idea for him to open that bug report I'd like to discuss
> this here.
>
> So the idea is to add support for ROL/ROR with Carry support as the
> current Rol*/Ror* functions don't support that. Florian then said that
> he's open to suggestions under some restrictions. Considering that the
> current Rol*/Ror* intrinsics aren't available for all platforms as
> intrinsics either, but as functions then, this could be done to support
> CPUs without suitable Carry support as well. And the code snippet that
> jamie showed would be a nice base:
>
> === code begin ===
>
> Function ROLByteWithCarry(Const AByte:Byte; Var
> ACarry:Boolean):Byte;Inline;
> var
> LocalIn:Boolean;
> Begin
> LocalIN := Acarry;
> ACarry := ShortInt(Abyte) < 0;
> Result := (AByte shl 1);
> IF LocalIn then Result := Result or 1;
> End;
>
> === code end ===
>
> Am I missing something?
>
>
The question is what one wants to achieve. The performance of rcl/rcr is
not really exiting either (throughput 4 times lower than that of
shl/shr). Can someone please provide an algorithm which uses
ROLByteWithCarry?
More information about the fpc-devel
mailing list