Rosario1903 wrote:
>>beside that PUSHAD is equal fast as pushing three apart regs,
>>I can't see any advantage in pushing more than required and read
>>back stack contents almost in the same order they were pushed.
>>If you want to keep the value in EAX then it's more approbiate
>>to just save EAX by single push/pop or better don't touch it.
> i think *many* routines has need *all* registers eax, ebc,ecx edx ebp
> esi edi... so pushad and popad are easy to use for that, but if one
> has to return a result in eax, one has to write in the stack where is
> eax, so all is ok here... years ago i did not understand how change
> eax in the end of the routine and this stop me from use pushad/popad
> more, if OS-ABI can allow, one can use the position in the stack where
> are edx ecx as 2 varibles or 2 other return values other than eax
Yes, many years ago me too used this method with RosAsm:
(instead of the oh-so-famous PUSH EBP|MOV EBP,ESP|ADD ESP,xx -shit)
MainWindowProc: ;esp+00=ret +04=hdl +08=msg +0c=wP +10=lP
pushad
; mov edx D$esp+024 ;hdl not of interest here, just kept on stack
mov eax D$esp+028 ;msg
mov ebx D$esp+02c ;wP
; mov ecx D$esp+030 ;lP not of interest here, just kept on stack
cmp eax &WM_CHAR |jnz L7>>
...
popad
call ... ;can call an API which need this stack-contents
ret 16
find the whole story in KE05TEST.exe on my homepage under[codesnips].
__
wolfgang