Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to call an external API you need to include the appropriate *.inc file as well as the respective *.lib file.<br> Try to add these statements to your listing:</p> <pre><code>include \masm32\include\kernel32.inc includelib \masm32\lib\kernel32.lib </code></pre> <p>(assuming \masm32 referes to your masm32 dir)</p> <p><strong>Update:</strong><br> The prototype definition basically tells the assembler how many parameters the respective function expects on the stack. In your case the API expects one 32bit parameter to be on the stack, which is reflected by the prototype like this:</p> <pre><code>QueryPerformanceCounter PROTO :DWORD </code></pre> <p><strong>Update2:</strong><br> In order to use the performance counter API you need a quadword. The reason is, that the API expects a pointer to a quadword (64 bit) as the parameter (therefore the DWORD in the prototype):</p> <pre><code>LOCAL Freq :QWORD invoke QueryPerformanceFrequency, ADDR Freq </code></pre> <p>This should do the trick.</p> <p><strong>Update3:</strong><br> So here's a complete example which works for me: </p> <pre><code> .486 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\masm32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\masm32.lib doPerf PROTO .code start: invoke doPerf invoke ExitProcess,eax doPerf proc LOCAL Freq :QWORD invoke QueryPerformanceFrequency, ADDR Freq mov esi, dword ptr Freq mov edi, dword ptr Freq+4 ret doPerf endp end start </code></pre> <p>I guess that's it :) ESI and EDI now contain the result.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload