mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-23 20:29:33 +02:00
+ utility function to reverse the bit pattern of a Word
git-svn-id: trunk@35266 -
This commit is contained in:
parent
fd465ff500
commit
62fc960e63
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user