The MASM Forum

General => The Campus => Topic started by: xoreaxeax on July 27, 2012, 12:37:21 AM

Title: Pointer addr question
Post by: xoreaxeax on July 27, 2012, 12:37:21 AM
I just want to be sure, but is there any chance at all a valid pointer addr could equal 0?  Does the assembler/linker make sure that never happens?
Title: Re: Pointer addr question
Post by: hutch-- on July 27, 2012, 12:42:58 AM
No. A pointer address cannot be lower than the minimum address specified in the OS. Address 0 is an error in win 32. On my XP Sp3 the lowest address is 100000 hex.
Title: Re: Pointer addr question
Post by: dedndave on July 27, 2012, 11:04:36 AM
sometimes, a pointer of 0 or NULL is used to indicate the absence of a value
for example, some functions will fill a POINT structure if you provide an address
if you pass a NULL value, it will omit that feature
other times - i may set a pointer to 0 to indicate that it isn't filled in, yet

otherwise.....
a pointer of 0 will undoubtedly get you a crash and a look at Dr Watson or a maybe a debugger   :biggrin:
Title: Re: Pointer addr question
Post by: npnw on July 27, 2012, 02:48:05 PM
Couldn't it also depend on where he is in the program cycle. What about  dd (0) in the program header. Then if a pointer  is pointing to another it would be init with 0 or null to begin, so it could be garbage. Then as you were saying Dave it would fill it in with a valid address later on.

What about runtime pointer allocation on the fly? They could be set to a value such as 0 and then dynamically linked on the fly with a valid pointer.  I guess it depends on what pointer you were looking at and when.