Str2Bits Routines |
Unit
QESBPCSSystem
Overloaded Variants |
Function Str2Bits(var S: String16): TESBBitList; |
Function Str2Bits(var S: String32): TESBLongBitList; |
Declaration
Function Str2Bits(var S: String16): TESBBitList;
Parameters |
S | String to process. |
Category
Memory OperationsImplementation
function Str2Bits (var S: String16): TESBBitList; asm push esi // Preserve ESI push ebx // Preserve EBX mov esi, eax // Move Pointer to S ESI lodsb // Read Length Byte into AL sub ah, ah // Clear AH mov cx, ax // CX <- AX, CX now has the length sub bx, bx // Clear BX for BitList construction mov dl, '0' // For comparisons @@Loop: lodsb // Load Next Character in AL shl bx, 1 // BX <- BX * 2 cmp al, dl // Is AL = '0' je @@NoOne // If Yes then it is Not a One and Jump add bx, 1 // Otherwise add 1 @@NoOne: Loop @@Loop // Loop till string all processed mov ax, bx // AX <- BX for function result pop ebx // Restore EBX pop esi // Restore ESI End; |
Declaration
Function Str2Bits(var S: String32): TESBLongBitList;Implementation
function Str2Bits (var S: String32): TESBLongBitList; asm push esi // Preserve ESI push ebx // Preserve EBX mov esi, eax // Move Pointer to S to ESI lodsb // Read Length Byte into AL sub ah, ah // Clear AH mov cx, ax // CX <- AX, CX now has the length sub ebx, ebx // Clear EBX for BitList construction mov dl, '0' // For comparisons @@Loop: lodsb // Load Next Character in AL shl ebx, 1 // EBX <- EBX * 2 cmp al, dl // Is AL = '0' je @@NoOne // If Yes then it is Not a One and Jump add ebx, 1 // Otherwise add 1 @@NoOne: Loop @@Loop // Loop till string all processed mov eax, ebx // EAX <- EBX for function result pop ebx // Restore EBX pop esi // Restore ESI End; |
|