Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1.  proc string.length uses ebx, _str
  2.     mov     eax, 0
  3.     mov     ebx, [_str]
  4.   @@:
  5.     cmp     [ebx], byte 0
  6.     je      @f
  7.     inc     eax
  8.     inc     ebx
  9.     jmp     @b
  10.   @@:
  11.     ret
  12.  endp
  13.  
  14.  proc string.copy uses eax ebx ecx, _src, _dst
  15.     mov     eax, [_src]
  16.     mov     ebx, [_dst]
  17.   @@:
  18.     mov     cl, [eax]
  19.     mov     [ebx], cl
  20.     cmp     cl, 0
  21.     je      @f
  22.     inc     eax
  23.     inc     ebx
  24.     jmp     @b
  25.   @@:
  26.     ret
  27.  endp
  28.  
  29.  proc string.concatenate uses eax, _src, _dst
  30.     stdcall string.length, [_dst]
  31.     add     eax, [_dst]
  32.     stdcall string.copy, [_src], eax
  33.     ret
  34.  endp
  35.  
  36.  proc string.compare uses ebx ecx edx, _str1, _str2
  37.     mov     eax, 0
  38.     mov     ebx, [_str1]
  39.     mov     ecx, [_str2]
  40.   @@:
  41.     mov     dl, [ebx]
  42.     cmp     dl, [ecx]
  43.     jne     .not_eq
  44.     cmp     dl, 0
  45.     je      @f
  46.     cmp     [ecx], byte 0
  47.     je      @f
  48.     inc     ebx
  49.     inc     ecx
  50.     jmp     @b
  51.  .not_eq:
  52.     mov     eax, -1
  53.   @@:
  54.     inc     eax
  55.     ret
  56.  endp
  57.  
  58.  proc string.to_lower_case uses eax, _str
  59.     mov     eax, [_str]
  60.   @@:
  61.     cmp     [eax], byte 0
  62.     je      @f
  63.     cmp     [eax], byte 65
  64.     jl      .next
  65.     cmp     [eax], byte 90
  66.     jg      .next
  67.     add     [eax], byte 97 - 65
  68.  .next:
  69.     inc     eax
  70.     jmp     @b
  71.   @@:
  72.     ret
  73.  endp
  74.  
  75.  proc string.to_upper_case uses eax, _str
  76.     mov     eax, [_str]
  77.   @@:
  78.     cmp     [eax], byte 0
  79.     je      @f
  80.     cmp     [eax], byte 97
  81.     jl      .next
  82.     cmp     [eax], byte 122
  83.     jg      .next
  84.     sub     [eax], byte 97 - 65
  85.  .next:
  86.     inc     eax
  87.     jmp     @b
  88.   @@:
  89.     ret
  90.  endp
  91.  
  92.  proc string.match uses ebx ecx edx, _str1, _str2
  93.     mov     ebx, [_str1]
  94.     mov     ecx, [_str2]
  95.   @@:
  96.     cmp     [ebx], byte 0
  97.     je      @f
  98.     cmp     [ecx], byte 0
  99.     je      @f
  100.  
  101.     mov     dl, [ebx]
  102.     cmp     [ecx], byte '?'
  103.     je      .next
  104.     cmp     [ecx], byte '*'
  105.     je      .next_ebx
  106.     cmp     [ecx], dl
  107.     je      .next
  108.  
  109.     cmp     [ecx - 1], byte '*'
  110.     je      .next_ecx
  111.  
  112.     jmp     @f
  113.  
  114.  .next_ecx:
  115.     dec     ecx
  116.     jmp     .next
  117.  .next_ebx:
  118.     dec     ebx
  119.  .next:
  120.     inc     ebx
  121.     inc     ecx
  122.     jmp     @b
  123.   @@:
  124.  
  125.   @@:
  126.     cmp     [ecx], byte 0
  127.     je      @f
  128.     cmp     [ecx], byte '*'
  129.     jne     @f
  130.     inc     ecx
  131.     jmp     @b
  132.   @@:
  133.  
  134.     cmp     [ecx], byte 0
  135.     je      @f
  136.     mov     eax, 0
  137.     ret
  138.   @@:
  139.     mov     eax, 1
  140.     ret
  141.  endp
  142.  
  143.  proc string.trim_last uses eax, _str
  144.     stdcall string.length, [_str]
  145.     add     eax, [_str]
  146.     dec     eax
  147.   @@:
  148.     cmp     [eax], byte ' '
  149.     jne     @f
  150.     mov     [eax], byte 0
  151.     dec     eax
  152.     jmp     @b
  153.   @@:
  154.     ret
  155.  endp
  156.  
  157.  proc string.trim_first, _str
  158.     mov     eax, [_str]
  159.   @@:
  160.     cmp     [eax], byte ' '
  161.     jne     @f
  162.     inc     eax
  163.     jmp     @b
  164.   @@:
  165.     ret
  166.  endp
  167.  
  168.  proc string.index_of uses ebx ecx, _str, _char, _num
  169.     mov     ebx, [_char]
  170.     mov     ecx, [_str]
  171.     mov     eax, 0
  172.   @@:
  173.     cmp     [ecx], byte 0
  174.     je      @f
  175.     cmp     [ecx], bl
  176.     jne     .after_check
  177.     dec     [_num]
  178.     jz      .finded
  179.  .after_check:
  180.     inc     ecx
  181.     inc     eax
  182.     jmp     @b
  183.   @@:
  184.     mov     eax, -1
  185.  .finded:
  186.     ret
  187.  endp
  188.  
  189.  proc string.last_index_of uses ebx ecx, _str, _char, _num
  190.     stdcall string.length, [_str]
  191.     mov     ecx, [_str]
  192.     add     ecx, eax
  193.     mov     ebx, [_char]
  194.   @@:
  195.     cmp     eax, 0
  196.     je      @f
  197.     cmp     [ecx], bl
  198.     jne     .after_check
  199.     dec     [_num]
  200.     jz      .finded
  201.  .after_check:
  202.     dec     ecx
  203.     dec     eax
  204.     jmp     @b
  205.   @@:
  206.     mov     eax, -2
  207.  .finded:
  208.     inc     eax
  209.     ret
  210.  endp