Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;  Copyright (C) Vasiliy Kosenko (vkos), 2009                                                    ;;
  3. ;;  This program is free software: you can redistribute it and/or modify it under the terms of    ;;
  4. ;;  the GNU General Public License as published by the Free Software Foundation, either version 3 ;;
  5. ;;  of the License, or (at your option) any later version.                                        ;;
  6. ;;                                                                                                ;;
  7. ;;  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;     ;;
  8. ;;  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     ;;
  9. ;;  See the GNU General Public License for more details.                                          ;;
  10. ;;                                                                                                ;;
  11. ;;  You should have received a copy of the GNU General Public License along with this program.    ;;
  12. ;;  If not, see <http://www.gnu.org/licenses/>.                                                   ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  16. ;;  Now there is only one function now: find string in array of strings                           ;;
  17. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  18.  
  19. ;; int str_find_in_array(char **options, char *str)
  20. ;; NOTE: options should be zero-ended array
  21. str_find_in_array:
  22.         push ebx
  23.        
  24.         mov ebx, [esp+8]
  25.         cld
  26. .convert_nxt:
  27.         add ebx, 4
  28.         mov esi, dword [ebx-4]
  29.         test esi, esi
  30.         je .set_default                         ;; String is incorrect, so set default
  31.         mov edi, [esp+0xc]
  32. .conv_loop:
  33.         cmpsb
  34.         jne .convert_nxt                        ;; Not equal, so try next
  35.         dec esi
  36.         lodsb
  37.         test al, al
  38.         jne .conv_loop
  39. .found:
  40.         sub ebx, [esp+8]
  41.         shr ebx, 2
  42.         mov eax, ebx
  43. .exit:
  44.         dec eax
  45.         pop ebx
  46.         ret
  47. .set_default:
  48.         xor eax, eax
  49.         jmp .exit
  50.