diff options
-rw-r--r-- | lowlevelunit.pas | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lowlevelunit.pas b/lowlevelunit.pas index cf6f883..7ad86a4 100644 --- a/lowlevelunit.pas +++ b/lowlevelunit.pas @@ -82,6 +82,10 @@ function hexDump(p: pointer; cnt: longint): string; function base64ToBin(var s: string): boolean; function base64Decode(const s: string; out i: qword): boolean; overload; function base64Decode(const s: string; out i: longword): boolean; overload; +function mirrorBits(qw: qword): qword; overload; +function mirrorBits(lw: longword): longword; overload; +function mirrorBits(w: word): word; overload; +function mirrorBits(b: byte): byte; overload; var base64Chars: array[0..63] of char; @@ -709,6 +713,40 @@ begin i:=0; end; +function mirrorBits(qw: qword): qword; +begin + result:= + (mirrorBits(longword(qw and $ffffffff)) shl 32) or + mirrorBits(longword(qw shr 32)); +end; + +function mirrorBits(lw: longword): longword; +begin + result:= + (mirrorBits(word(lw and $ffff)) shl 16) or + mirrorBits(word(lw shr 16)); +end; + +function mirrorBits(w: word): word; +begin + result:= + (mirrorBits(byte(w and $ff)) shl 8) or + mirrorBits(byte(w shr 8)); +end; + +function mirrorBits(b: byte): byte; +begin + result:= + byte(odd(b shr 7)) or + (byte(odd(b shr 6)) shl 1) or + (byte(odd(b shr 5)) shl 2) or + (byte(odd(b shr 4)) shl 3) or + (byte(odd(b shr 3)) shl 4) or + (byte(odd(b shr 2)) shl 5) or + (byte(odd(b shr 1)) shl 6) or + (byte(odd(b)) shl 7); +end; + var b: byte; begin |