Pages: 1 [2]
|
 |
|
Author
|
Topic: About LOCAL string (Read 10947 times)
|
jj2007
|
For the lazy programmer - short and fast, works with all kind of LOCAL variables, including strings and structures: MyTest proc LOCAL MyVar1:DWORD, LocBuffer[120]:BYTE, MyVar2:DWORD call ClearLocals ret MyTest endp
ClearLocals proc ; put "call ClearLocals" as first instruction after LOCALS - eax will be unchanged on exit push eax ; do not use with uses esi etc - push them manually behind the call! lea eax, [esp+8] ; pushed eax and ret address mov esp, ebp ; base page of calling procedure align 4 ; 74 instead of 123 cycles on Celeron M, no effect on P4 @@: push 0 ; 120 bytes: 196 cycles on P4 cmp esp, eax ; rep stosd?? ja @B sub esp, 8 ; 19 bytes with align 4 pop eax ret ClearLocals endp
|
|
|
Logged
|
|
|
|
NightWare
Member
    
Gender: 
Posts: 416
when dream comes true
|
LOCAL szDir[124]:BYTE
how to initialize it to all 0? like this szBuffer db 124 dup(0)
when i define a LOCAL Var, what is the default value inside?
to init/re-init a string you just need to clean the first byte, here : mov BYTE PTR szDir,0 coz there is NO REASONS to clean the entire area (at least if your string functions are well coded...).
|
|
|
Logged
|
|
|
|
ecube
Guest
|
You guys like the caps...I tend to use buffers for alot more than strings, and that's why I recommended the full clearing, is a piece of mind for me and doesn't limit. If he's sure he's just gonna mess with strings then YEAH, clearing the first byte is sufficient.
|
|
|
Logged
|
|
|
|
|
Pages: 1 [2]
|
|
|
 |