Guidance
指路人
g.yi.org
software / rapidq / Examples / ASM / CheckString / CheckString.RqAsm

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
;
; 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
;
.LoopCheckNextChar:
   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'
.CharOk:
   mov [edi], al
   inc edx
   inc edi
   jmp .LoopCheckNextChar
;
.EndOfCheck:
   mov eax, edx      ; returned value = returned string length
;
   pop edx
   pop ecx
   pop edi
   pop esi
end function

; code could be optimized ... using movsb ... ???
掌柜推荐
 
 
¥738.00 ·
 
 
¥1,480.00 ·
 
 
¥397.00 ·
 
 
¥950.00 ·
 
 
¥264.00 ·
 
 
¥1,005.00 ·
© Sun 2024-11-24  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2002-11-06 13:41:52