software / rapidq / Examples / ASM / CheckString / CheckString.RqAsm

Search 搜索
Home Home

; Rejects all character below 33 and over 127 in String to Work on
; and change lowercase chars to uppercase chars : 'a' to 'A', 'z' to 'Z'
; The new string is written at pointer ptrReturnedString
; The function returns the length of the returnedString
; ptrString           a pointer to the string to work on
; stringLen           length of the string to work on (to allow binStrings)
; ptrReturnedString   a pointer to a buffer long enough for returned string
function CheckString ptrString stringLen ptrReturnedString
   push esi
   push edi
   push ecx
   push edx
   mov esi, ptrString
   mov edi, ptrReturnedString
   mov ecx, stringLen
   mov edx, 0        ; Returned String Char Counter       
   dec esi
   inc ecx
   inc esi
   dec ecx
   jz .EndOfCheck      ; finished
   mov al, [esi]
   cmp al, 33
         jc .LoopCheckNextChar  ; rejected below 33d, 33d not rejected
   cmp al, 128   
   jnc .LoopCheckNextChar ; rejected over 127d, 127d not rejected
   cmp al, 97        ; 97d : FROM 'a' to 'A'
   jc .CharOk
   cmp al, 123       ; 122d : TO 'z' to 'Z'
   jnc .CharOk
   sub al, 32        ; to uppercase  97='a' > 65='A'
   mov [edi], al
   inc edx
   inc edi
   jmp .LoopCheckNextChar
   mov eax, edx      ; returned value = returned string length
   pop edx
   pop ecx
   pop edi
   pop esi
end function

; code could be optimized ... using movsb ... ???
© Sat 2024-4-20  Guidance Laboratory Inc. Hits:0 Last modified:2002-11-06 13:41:52