mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-18 21:02:34 +03:00
178 lines
3.7 KiB
PHP
178 lines
3.7 KiB
PHP
|
;
|
|||
|
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> ࠡ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD><EFBFBD>묨 <EFBFBD>㭪<EFBFBD><EFBFBD>ﬨ
|
|||
|
;
|
|||
|
|
|||
|
; str_len (str1)
|
|||
|
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>頥<EFBFBD><EFBFBD><EFBFBD> <EFBFBD> eax)
|
|||
|
|
|||
|
; str_cat (str1, str2)
|
|||
|
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> st1 <EFBFBD><EFBFBD>ப<EFBFBD> str2
|
|||
|
|
|||
|
; str_n_cat (str1, str2, n_len)
|
|||
|
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> st1 <EFBFBD><EFBFBD>ப<EFBFBD> str2. <EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> str2 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 祬 n_len, <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> n_len ᨬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
|||
|
; conv_str_to_int (buf)
|
|||
|
; <EFBFBD>८<EFBFBD>ࠧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> buf <EFBFBD> <EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>頥<EFBFBD><EFBFBD><EFBFBD> <EFBFBD> eax)
|
|||
|
|
|||
|
; convert_int_to_str (len)
|
|||
|
; <EFBFBD>८<EFBFBD>ࠧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> (eax) <EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> (edi). len - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> edi, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ᯮ<EFBFBD>짮<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD>८<EFBFBD>ࠧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
|
|||
|
|
|||
|
;output:
|
|||
|
; eax = strlen
|
|||
|
align 4
|
|||
|
proc str_len, str1:dword
|
|||
|
mov eax,[str1]
|
|||
|
@@:
|
|||
|
cmp byte[eax],0
|
|||
|
je @f
|
|||
|
inc eax
|
|||
|
jmp @b
|
|||
|
@@:
|
|||
|
sub eax,[str1]
|
|||
|
ret
|
|||
|
endp
|
|||
|
|
|||
|
align 4
|
|||
|
proc str_cat uses eax ecx edi esi, str1:dword, str2:dword
|
|||
|
mov esi,[str2]
|
|||
|
stdcall str_len,esi
|
|||
|
mov ecx,eax
|
|||
|
inc ecx
|
|||
|
mov edi,[str1]
|
|||
|
stdcall str_len,edi
|
|||
|
add edi,eax
|
|||
|
cld
|
|||
|
repne movsb
|
|||
|
ret
|
|||
|
endp
|
|||
|
|
|||
|
align 4
|
|||
|
proc str_n_cat uses eax ecx edi esi, str1:dword, str2:dword, n_len:dword
|
|||
|
mov esi,[str2]
|
|||
|
mov ecx,[n_len]
|
|||
|
mov edi,[str1]
|
|||
|
stdcall str_len,edi
|
|||
|
add edi,eax
|
|||
|
cld
|
|||
|
repne movsb
|
|||
|
mov byte[edi],0
|
|||
|
ret
|
|||
|
endp
|
|||
|
|
|||
|
;input:
|
|||
|
; buf - 㪠<EFBFBD><EFBFBD>⥫<EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD>, <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> 10 <EFBFBD><EFBFBD><EFBFBD> 16 <EFBFBD><EFBFBD>筮<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
;output:
|
|||
|
; eax - <EFBFBD><EFBFBD>
|
|||
|
align 4
|
|||
|
proc conv_str_to_int uses ebx ecx esi, buf:dword
|
|||
|
xor eax,eax
|
|||
|
xor ebx,ebx
|
|||
|
mov esi,[buf]
|
|||
|
;<EFBFBD><EFBFBD>।<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥫<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ᥫ
|
|||
|
xor ecx,ecx
|
|||
|
inc ecx
|
|||
|
cmp byte[esi],'-'
|
|||
|
jne @f
|
|||
|
dec ecx
|
|||
|
inc esi
|
|||
|
@@:
|
|||
|
|
|||
|
cmp word[esi],'0x'
|
|||
|
je .load_digit_16
|
|||
|
|
|||
|
.load_digit_10: ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD>뢠<EFBFBD><EFBFBD><EFBFBD> 10-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
mov bl,byte[esi]
|
|||
|
cmp bl,'0'
|
|||
|
jl @f
|
|||
|
cmp bl,'9'
|
|||
|
jg @f
|
|||
|
sub bl,'0'
|
|||
|
imul eax,10
|
|||
|
add eax,ebx
|
|||
|
inc esi
|
|||
|
jmp .load_digit_10
|
|||
|
jmp @f
|
|||
|
|
|||
|
.load_digit_16: ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD>뢠<EFBFBD><EFBFBD><EFBFBD> 16-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
add esi,2
|
|||
|
.cycle_16:
|
|||
|
mov bl,byte[esi]
|
|||
|
cmp bl,'0'
|
|||
|
jl @f
|
|||
|
cmp bl,'f'
|
|||
|
jg @f
|
|||
|
cmp bl,'9'
|
|||
|
jle .us1
|
|||
|
cmp bl,'A'
|
|||
|
jl @f ;<EFBFBD><EFBFBD>ᥨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᨬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> >'9' <EFBFBD> <'A'
|
|||
|
.us1: ;<EFBFBD><EFBFBD><EFBFBD>⠢<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
cmp bl,'F'
|
|||
|
jle .us2
|
|||
|
cmp bl,'a'
|
|||
|
jl @f ;<EFBFBD><EFBFBD>ᥨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᨬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> >'F' <EFBFBD> <'a'
|
|||
|
sub bl,32 ;<EFBFBD><EFBFBD>ॢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᨬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD>孨<EFBFBD> ॣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>饭<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>饩 <EFBFBD><EFBFBD>ࠡ<EFBFBD>⪨
|
|||
|
.us2: ;<EFBFBD><EFBFBD><EFBFBD>⠢<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
sub bl,'0'
|
|||
|
cmp bl,9
|
|||
|
jle .cor1
|
|||
|
sub bl,7 ;convert 'A' to '10'
|
|||
|
.cor1:
|
|||
|
shl eax,4
|
|||
|
add eax,ebx
|
|||
|
inc esi
|
|||
|
jmp .cycle_16
|
|||
|
@@:
|
|||
|
or ecx,ecx ;<EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥫쭮<EFBFBD>
|
|||
|
jnz @f
|
|||
|
neg eax
|
|||
|
inc eax
|
|||
|
@@:
|
|||
|
ret
|
|||
|
endp
|
|||
|
|
|||
|
;input:
|
|||
|
; eax - <EFBFBD><EFBFBD>
|
|||
|
; edi - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD>
|
|||
|
; len - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
;output:
|
|||
|
align 4
|
|||
|
proc convert_int_to_str, len:dword
|
|||
|
pushad
|
|||
|
mov esi,[len]
|
|||
|
add esi,edi
|
|||
|
dec esi
|
|||
|
bt eax,31
|
|||
|
jae @f
|
|||
|
;<EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥫쭮<EFBFBD>
|
|||
|
neg eax
|
|||
|
;inc eax ;???
|
|||
|
mov byte[edi],'-'
|
|||
|
inc edi
|
|||
|
@@:
|
|||
|
call .str
|
|||
|
popad
|
|||
|
ret
|
|||
|
endp
|
|||
|
|
|||
|
align 4
|
|||
|
.str:
|
|||
|
mov ecx,0x0a ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>⥬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ॣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ebx,eax,ecx,edx <EFBFBD>室<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ࠬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> eax - <EFBFBD><EFBFBD>
|
|||
|
;<EFBFBD><EFBFBD><EFBFBD>ॢ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD> ASCII <EFBFBD><EFBFBD>ப<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ecx=<EFBFBD><EFBFBD><EFBFBD>⥬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> edi <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>㤠 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뢠<EFBFBD><EFBFBD>, <EFBFBD>㤥<EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD>祬 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>६<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
cmp eax,ecx ;<EFBFBD>ࠢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD> eax <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 祬 <EFBFBD> ecx <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>३<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> @@-1 <EFBFBD>.<EFBFBD>. <EFBFBD><EFBFBD> pop eax
|
|||
|
jb @f
|
|||
|
xor edx,edx ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> edx
|
|||
|
div ecx ;ࠧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>⮪ <EFBFBD> edx
|
|||
|
push edx ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD>⥪
|
|||
|
;dec edi ;ᬥ饭<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>室<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD>
|
|||
|
call .str ;<EFBFBD><EFBFBD>३<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ᠬ<EFBFBD> ᥡ<EFBFBD> <EFBFBD>.<EFBFBD>. <EFBFBD>맢<EFBFBD><EFBFBD><EFBFBD> ᠬ<EFBFBD> ᥡ<EFBFBD> <EFBFBD> ⠪ <EFBFBD><EFBFBD> ⮣<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> eax <EFBFBD><EFBFBD> <EFBFBD>⠭<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 祬 <EFBFBD> ecx
|
|||
|
pop eax
|
|||
|
@@: ;cmp al,10 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>祭<EFBFBD><EFBFBD> <EFBFBD> al 祬 10 (<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>⥬<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> - <EFBFBD><EFBFBD>譠<EFBFBD>))
|
|||
|
cmp edi,esi
|
|||
|
jge @f
|
|||
|
or al,0x30 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 祬 <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
stosb ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ॣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> al <EFBFBD> <EFBFBD>祪<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> es:edi
|
|||
|
mov byte[edi],0 ;<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ப<EFBFBD> <EFBFBD>⠢<EFBFBD><EFBFBD> 0, <EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD>뫠<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
@@:
|
|||
|
ret ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD>⥪<EFBFBD> <EFBFBD>࠭<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD> <EFBFBD>맮<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD>⮫쪮 ࠧ <EFBFBD><EFBFBD> <EFBFBD> <EFBFBD>㤥<EFBFBD> <EFBFBD><EFBFBD><EFBFBD>뢠<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|