in my code i using EDX.EBX,EAX to preserve some datas in a loop , but now in that loop i have to call a procedure that use api functions, obviouly y gona loos the data on the register, but reading the MASM manuals , i found some thing about preserv some register datas,

MyProcedure proc USES EDX,EBX,ECX MyVar:DWORD
....

the USES sentence , WHAT's DO exactly?....if i thought correctly WHERE STORES THE ORIGINAL VALUES?
Posted on 2003-03-04 09:22:33 by DrBios


MyProc PROC USES ebx,esi,edi
...
ret
MyProc ENDP

is basically the same as


MyProc PROC
push ebx
push esi
push edi
...
pop edi
pop esi
pop ebx
ret
MyProc ENDP
Posted on 2003-03-04 09:28:36 by Tola
so ..it store the values on the stack , and at the end of the procedure the values are push to the original register, but what happens if i use the stack?
Posted on 2003-03-04 09:33:44 by DrBios
If YOUR procedure uses the stack normally, there is no problem. If you are concerned with the effect of API calls, those procedures also return the stack to where it was prior to calling such procedures, including cleaning up passed parameters.

If you are still concerned, push (save) the registers yourself on the stack BEFORE calling your procedure and pop them after you return. If you use that procedure elsewhere in your code, those registers may not need to be saved on those occasions. (If you don't use that procedure elsewhere, why write it as a procedure!)

Raymond
Posted on 2003-03-04 10:06:38 by Raymond
mmmmm...now i get it clear...thanks guys
Posted on 2003-03-04 10:17:52 by DrBios