+ utility function to reverse the bit pattern of a Word

git-svn-id: trunk@35266 -
This commit is contained in:
svenbarth 2017-01-08 16:06:29 +00:00
parent fd465ff500
commit 62fc960e63

View File

@ -65,6 +65,8 @@ interface
function newalignment(oldalignment: longint; offset: int64): longint;
{# Return @var(b) with the bit order reversed }
function reverse_byte(b: byte): byte;
{# Return @var(w) with the bit order reversed }
function reverse_word(w: word): word;
function next_prime(l: longint): longint;
@ -273,6 +275,17 @@ implementation
reverse_byte:=(reverse_nible[b and $f] shl 4) or reverse_nible[b shr 4];
end;
function reverse_word(w: word): word;
type
TWordRec = packed record
hi, lo: Byte;
end;
begin
TWordRec(reverse_word).hi := reverse_byte(TWordRec(w).lo);
TWordRec(reverse_word).lo := reverse_byte(TWordRec(w).hi);
end;
function align(i,a:longint):longint;{$ifdef USEINLINE}inline;{$endif}
{
return value <i> aligned <a> boundary