I have a struture which is correctly allocated at address 0x4000 (read from the M66 file). The DPP0 is used by Keil to point to the NDATA memory chunk: DPP0 = 1 so the pointer to my struture, when stored in a register is 0x0000!!!! Unfortunately, I check if this value is different from a NULL pointer. The generated assembly code is: CMP R15 #0 JMPR CC_Z, ..... where R15=0, which is the right value to point to 0x4000 with DPP0=1 and MUST not be interpreted as a NULL pointer! Is it a bug?? The memory configuration is 0->0x3999 of ROM 0x4000 -> 0x24000 RAM Near memory model: 32k RAM, 16K ROM
Is it a bug?? From your description, it does sound like a bug. Looks like one of those "corner cases." Sorry, bad luck... Regards, - mike
Well as pointed out this is one of the corner cases. You need to start your memory at 0x4001 so that the value 0x4000 cannot be mapped to 0. Reinhard
Yes, I can obviously start the memory at 0x4001.... But the bug will still be there. I hope such a bug won't appear in the embedded code in my car :-(
"Well as pointed out this is one of the corner cases." So there are more? It would be nice to know what they are so you can watch out for them. Sauli
PC compilers commonly locate a 16 or 32 byte long segment at offset 0x0000. Usually, this segment contains a string like "NULL Pointer Access". NULL pointer access checking compares this string with the actual memory contents to detect assignments to NULL pointers. The following KB article describes how to do this using the uVision Debugger: http://www.keil.com/support/docs/174.htm. In an embedded system NULL pointer assignments cannot be handled very well by the compiler since there is no standard operating system or display to accommodate message output. So, you must handle them yourself (if appropriate). Jon