I have downloaded some sample code from the internet and I am trying to understand it. The problem I have is I do not understand why the paramaters of the function are being loaded into the registers as DWORD PTR. Hope you can help.


; double dasum(int n, const double * x, int incx)

push ecx
push esi
push eax
mov ecx, DWORD PTR
mov esi, DWORD PTR
mov eax, DWORD PTR
Posted on 2004-05-25 17:45:45 by Liamo
"push ecx" is the same as:

sub esp, 4
mov , ecx

...the best way to see what is happening is to use a debugger that displays the stack - like OllyDbg.
Posted on 2004-05-25 17:56:11 by bitRAKE
Thanks for taking the time to respond. I understand the push command however the part of the code I do not understand is

mov ecx, DWORD PTR

I understand that the return address oif the caller is pushed first and then the registers used in the code are pushed giving the value of 16 used in the square brackets. The part I find confusing is the DWORD PTR since we are dealing with a VALUE of n.

Posted on 2004-05-25 18:30:15 by Liamo
ESP is an address (pointer) used to access memory. DWORD PTR just means to use the pointer to access four bytes. It is redundant in this case since ECX is 32 bit. Imagine if we were storing an immediate value:

mov , 1

...here it is not so clear what should be put at the address . Is it a byte, word, dword? In this case we must explicitly state the size. MASM doesn't always require DWORD PTR to be specified.
Posted on 2004-05-25 18:58:39 by bitRAKE