I am trying to calculate a simple checksum on my code. I am doing something like this:
unsigned short Index, Checksum = 0; unsigned char code * data pCode = 0; for( Index = 0; Index < end_of_code; Index++ ) { Checksum += *pCode++; }
How can I get the linker to fill in the 'end_of_code' address or the size of the code segment?
Thanks, Dan
I tried the suggestion at:
http://www.keil.com/support/docs/2681.htm
but that didn't place the module at the end of the code segment. It turns out that I was running into the same problem that Hans-Bernhard ran into concerning gaps (see http://www.keil.com/forum/docs/thread5659.asp). Once I made the variable an array that was larger than the gap, it was placed at the end of my code. Not really a good solution since every time I build, I'll have to make sure that the linker didn't make the gap larger and place the end of code marker in it.
I agree with Andy - why don't they just make the linker assign a special symbol that represents the end of code?
"why don't they just make the linker assign a special symbol that represents the end of code?"
See: http://www.keil.com/forum/docs/thread12128.asp