News:

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

Invoke

Started by 2-Bit Chip, November 24, 2009, 10:26:31 PM

Previous topic - Next topic

jj2007

Quote from: sinsi on November 25, 2009, 07:42:20 AM
I like ml64 because it is stripped down - I control everything (sorry goasm) and that's why I use asm.
I've said before that I don't even like using 'invoke' - heretic! burn him! - more abstraction.

'Masos' - is that 'masochists'? Umm, yeah, hit me. 'masos' sounds vaguely to do with sex...hang on...


Sinsi, make up your mind: Do you want to get burnt or hit??
:bg

sinsi

All the same to us masos. combo x2!!
Light travels faster than sound, that's why some people seem bright until you hear them.

jj2007

Hmmm... before the moderator bans us from the Campus, here an interesting example comparing the pop/jmp, frameless and framed calls :bg

Quoteinclude \masm32\include\masm32rt.inc

.686
include \masm32\macros\timers.asm         ; get them from the Masm32 Laboratory
LOOP_COUNT   = 1000000

ChkCostOfAdditionalCode = 0

if ChkCostOfAdditionalCode
   AddCode$ equ <imul eax, eax, 100>
else
   AddCode$ equ <>
endif

codesize MACRO algo
   @CatStr(<mov edx, algo>, <_endp>)
   sub edx, algo
   EXITM <edx>
ENDM

.code
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE
align 16
MyTestPop proc OneArg
   pop edx
   pop eax      ; OneArg
   AddCode$
   jmp edx
MyTestPop endp
MyTestPop_endp:

align 16
MyTestNoFrame proc OneArg
   mov eax, [esp+4]      ; OneArg
   AddCode$
   ret 4
MyTestNoFrame endp
MyTestNoFrame_endp:

OPTION PROLOGUE:Prologuedef
OPTION EPILOGUE:Epiloguedef
align 16
MyTestFrame proc OneArg
   mov eax, OneArg
   AddCode$
   ret
MyTestFrame endp
MyTestFrame_endp:

start:
   counter_begin LOOP_COUNT, HIGH_PRIORITY_CLASS
      REPEAT 10
      invoke MyTestPop, 123
      ENDM
   counter_end
   print str$(eax), 9, "cycles for 10*MyTestPop, size "
   print str$(codesize(MyTestPop)), 13, 10

   counter_begin LOOP_COUNT, HIGH_PRIORITY_CLASS
      REPEAT 10
      invoke MyTestNoFrame, 123
      ENDM
   counter_end
   print str$(eax), 9, "cycles for 10*MyTestNoFrame, size "
   print str$(codesize(MyTestNoFrame)), 13, 10

   counter_begin LOOP_COUNT, HIGH_PRIORITY_CLASS
      REPEAT 10
      invoke MyTestFrame, 123
      ENDM
   counter_end
   print str$(eax), 9, "cycles for 10*MyTestFrame, size "
   print str$(codesize(MyTestFrame)), 13, 10

   getkey
   exit
end start

sinsi


38      cycles for 10*MyTestPop, size 4
38      cycles for 10*MyTestNoFrame, size 7
50      cycles for 10*MyTestFrame, size 10

Banned? Nah, just binned.
Light travels faster than sound, that's why some people seem bright until you hear them.

dedndave

from what i can see, push and pop are pretty fast
it's hard for me to make any concrete statements with this "sloppy-times" prescott CPU
so, i have to keep qualifying statements with things like "from what i can see, ..." - lol
the problem i have with pop...jmp is it uses a register
in most procs i write, the register is valuable and i use all of them to make the code faster
i am no big fan of stack frames, either - lol
but, the API is designed that way, and i want my procs to be more or less "compatible"
i can see cases where, if you have only one or two parms and access them only one time.....

        mov     eax,[esp+4N]

saves you the overhead of setting up a stack frame pointer in ebp
i see some guys accessing stuff underneath esp
you won't see me doing that, no matter how hard you try to convince me that it's ok - lol
i think that is inviting strange behaviour into an otherwise well-behaved application