News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

uses directive

Started by ecube, October 12, 2009, 07:12:03 AM

Previous topic - Next topic

ecube

is there any downsides/dangerous to using uses? and what registers does the winapi preserve?

sinsi

dangerous: why? all it does is automatically push and pop the registers
downside: I'm not sure if using "option prolog:none" changes things

winapi: saves ebx,esi,edi,ebp
Light travels faster than sound, that's why some people seem bright until you hear them.

hutch--

Cube,

It works OK, just sppecify the registers you want preserved and it will automatically di it for you but there is a down side, if you have multiple exits from the procedure, it write multiple copies of the stack balancing code which may not be what you want in terms of size. I always do my own manually.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

Quote from: sinsi on October 12, 2009, 07:35:52 AM
downside: I'm not sure if using "option prolog:none" changes things

It does. No pushn & poppin with PROLOGUE:NONE...  check yourself

include \masm32\include\masm32rt.inc

MyProc PROTO: DWORD, :DWORD, :DWORD

.code
start: int 3  ; greetings to Olly
invoke MyProc, 123,456, 789
exit

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
MyProc proc uses esi edi ebx arg1_:DWORD, arg2_:DWORD, arg3_:DWORD
  ret 4*3
MyProc endp
MyProc_END: ; label for csize macro
OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef

sinsi

I used to have a macro (xpush/xpop) so you could use "xpush ebx,esi,edi" on one line

Quote from: jj2007 on October 12, 2009, 07:42:44 AM
It does. No pushn & poppin with PROLOGUE:NONE...  check yourself
Thought so. I was just too lazy to test it...
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

i am not sure the api keeps the direction flag cleared, but it should be included in the list with ebx, esi, edi, ebp
you are expected to keep it cleared