Hi! I have a question (stupid or not). What is the difference between the value NULL and 0 for any param? I ask you that because i have found (i don't remember where) that there is no difference (i used NULL and 0 as a value of param, and didn't see any changes), but in the Iczelion's tut no.13 (Memory mapped files) i see that he uses NULL and 0 in CreateFile (and CreateFileMapping) function. I also change this 0 to NULL in example and did't see any change (only try with CreateFile). Can somebody explain please. Thank you Greetz
Posted on 2001-02-15 12:53:00 by stanks
well the constant NULL == 0 but NULL as a value != 0 NULL as a value is nothing, empty whereas 0 stil is a number: 0 NULL probably wrote/read easier for Iczelion in that example.
Posted on 2001-02-15 12:55:00 by Hiroshimator
If you search through windows.inc, you will discover: NULL equ 0 So why alias zero? Readability. If you call an procedure with:

    invoke SetCount, 0
it's obvious you want to reset a number. If you call another procedure with

    invoke SetPointer, NULL
you are also setting the pointer value to zero, but reading this line lets someone know you set it to an undefined value. In both these cases, the same code is generated:

6A 00	        *	    push   +000000000h
E8 00000000 E   *	    call   {some procedure}
Where it DOES matter is setting a register or memory location. It is a bit faster to xor either with itself to zero it out.

B8 00000000		    mov eax, NULL
33 C0	  	            xor eax,eax
Posted on 2001-02-15 13:15:00 by Ernie
stanks, As has been already said here, NULL is an equate to 0 but just be careful of what an API requires, somw will accept NULL as a parameter where some require the address of a NULL byte. Its easy enough to handle, just make a BYTE size data item in the .data section, MyNull db 0 and either use ADDR MyNull in an invoke call as the parameter or mov REG, offset MyNull if you chose to do the API call manually. Regards, hutch@pbq.com.au
Posted on 2001-02-15 18:27:00 by hutch--
In a very strict C++ environment, NULL is always an address. In Win32, this is always the address 0. With much less type checking in ASM, it makes no difference (in code) whether you use NULL or 0.
Posted on 2001-02-16 15:08:00 by tank