Hossa
1.
how can i show the string i found in big words ?
example TeSt = TEST
2.
how can i show "count dd 52" as "countbuff db 256 dup(0)" ?
i use actual :
.if count==1
do action
.elseif count==2
do next
....
...
...
what is very lame :)
3.
How can i get the extension of a file i found ?
example Test.exe = exe
Thanks
1.
how can i show the string i found in big words ?
example TeSt = TEST
2.
how can i show "count dd 52" as "countbuff db 256 dup(0)" ?
i use actual :
.if count==1
do action
.elseif count==2
do next
....
...
...
what is very lame :)
3.
How can i get the extension of a file i found ?
example Test.exe = exe
Thanks
1) If you know the string contains only letters (no numbers or other symbols), then you can do:
2)
3) Search backwards for the first instance of the "." in your string.
Mirno
push esi
mov esi, OFFSET string
xor ecx, ecx
@@:
mov al, [esi + ecx]
or al, al
jz end
; You may want to test if it is a character here!
or al, 00000020h ; lower case
; and al, 0FFFFFFDFh ; upper case
mov [esi + ecx], al
inc ecx
jmp @B
end:
pop esi
2)
invoke dwtoa, count, ADDR countbuff
3) Search backwards for the first instance of the "." in your string.
Mirno
Thanks for quick help Mirno
but some questions i have :
2)
code:--------------------------------------------------------------------------------
invoke dwtoa, count, ADDR countbuff
------------------------------------------------------------------------
sorry thats what i mean in another posting from me ,how to do some things without "readymade" functions is lost it seams :)
since i use Tasm this is not working for me and i need to know how to do this without a "readymade" function ;)
but thanks for taking the time to answer mirno ,im an exot :)
i use some lame function to convert it ,im a big beginner :)
my .data is very big because
string_1 db '1',0
string_2 db '2',0
string_3 db '3',0
string_4 db '4',0
up to 100
count dd 0
now i read all files from a directory and use inc count to count them up.
then i use
.if count==1
setdlg.....string_1
.elseif count==2
setdlg--string_2
....
....
.....
up to 100
first it look very ugly ,next its very slow and last it make program bigger then it need :(
any ideas how i can convert this ?
if its not to lame to ask for i would like to see/find a tutorial about converting values :)
Thanks
but some questions i have :
2)
code:--------------------------------------------------------------------------------
invoke dwtoa, count, ADDR countbuff
------------------------------------------------------------------------
sorry thats what i mean in another posting from me ,how to do some things without "readymade" functions is lost it seams :)
since i use Tasm this is not working for me and i need to know how to do this without a "readymade" function ;)
but thanks for taking the time to answer mirno ,im an exot :)
i use some lame function to convert it ,im a big beginner :)
my .data is very big because
string_1 db '1',0
string_2 db '2',0
string_3 db '3',0
string_4 db '4',0
up to 100
count dd 0
now i read all files from a directory and use inc count to count them up.
then i use
.if count==1
setdlg.....string_1
.elseif count==2
setdlg--string_2
....
....
.....
up to 100
first it look very ugly ,next its very slow and last it make program bigger then it need :(
any ideas how i can convert this ?
if its not to lame to ask for i would like to see/find a tutorial about converting values :)
Thanks
And if you want to check the extension of some file :
xor al, al ; scan untill nul terminator
mov edi, pFileName
or edi,edi
jz not_exe
repnz scasb
std
mov al,'.' ; scan backward untill '.'
or edi,edi
jz not_exe
repnz scasb
cld
cmp dword ptr ,'exe.' ; check extention
jz ok
jmp not_exe
ok:
not_exe:
[\QUOTE]
xor al, al ; scan untill nul terminator
mov edi, pFileName
or edi,edi
jz not_exe
repnz scasb
std
mov al,'.' ; scan backward untill '.'
or edi,edi
jz not_exe
repnz scasb
cld
cmp dword ptr ,'exe.' ; check extention
jz ok
jmp not_exe
ok:
not_exe:
[\QUOTE]
one scasb does it too I think :)
note that some extesions are ~UPPERCASE~ ...
thats why i use "or" to receive only lowercase ext's
mov edi, offset FileName
mov al, 46
repnz scasb
or dword ptr [edi ], 20202020h
cmp dword ptr [ edi ], "exe."
note that some extesions are ~UPPERCASE~ ...
thats why i use "or" to receive only lowercase ext's
Here is a very unoptimised procedure to count a string's length
Its TASM version and it works ...
you can optimise it later ;)
usage:
Call Calc_len_str,offset my_sz_string ; similar to MASM invoke
mov ,eax ; etc etc
Its TASM version and it works ...
you can optimise it later ;)
usage:
Call Calc_len_str,offset my_sz_string ; similar to MASM invoke
mov ,eax ; etc etc
;***********************************************
;
; Calculate length of a string
;
; input: -offset of string on stack
; output: -eax=length
;
;***********************************************
Calc_len_str proc
USES esi,ecx
ARG dwOffsetStr:DWORD
mov eax,[dwOffsetStr]
mov esi,eax
mov ecx,0 ; zero ecx to use as counter
cld ; read forward
calc_len_loop:
lodsb
cmp al,0 ; exit loop on zero
jz calc_len_end
inc ecx ; get string length excluding zero
jmp calc_len_loop
calc_len_end:
mov eax,ecx ; return value in eax
ret
Calc_len_str endp
Hossa
and another one for my coding database :)
thank you BogdanOntanu !
i normal use call lstrlen to get the lenght of a string but i like more to know how i can do this like you did.
happy coding
and another one for my coding database :)
thank you BogdanOntanu !
i normal use call lstrlen to get the lenght of a string but i like more to know how i can do this like you did.
happy coding
sorry but i have nothing to do at this time so
i'm pretty bored :) just to kill time...
i'm pretty bored :) just to kill time...
;INPUT: edi <- Offset String
;OUTPUT: String Lenght -> edi
_sl:push edi
xor al, al
repnz scasb
pop eax
sub edi, eax
ret