Why is the stack pointer out of range? I have a function that dumps the contents of the arduino's ram, and it works, but I still dont understand why it says my stack pointer is at 0x08C9 If the ram of the arduino is 2kb, or 2048 bytes, shouldent the max addressable size be 0x0800?

RAM: SP-&gt;0x08C9 HP-&gt;0x0371 FREE:1368


And the code:

void printAddress(uint16_t val)
{
  Serial.print(F("0x"));
  if(val &lt; 16)
{
 Serial.print(F("0"));
}
if(val &lt; 256)
 {
  Serial.print(F("0"));
}
if(val &lt; 4096)
{
  Serial.print(F("0"));
}
Serial.print(val,HEX);
}

void setup(){
Serial.begin(115200);
//0x0800 2048
uint8_t *heapptr, *stackptr;
stackptr = (uint8_t *)malloc(4);        // use stackptr temporarily
heapptr = stackptr;                     // save value of heap pointer
free(stackptr);                         // free up the memory again (sets stackptr to 0)
stackptr =  (uint8_t *)(SP);            // save value of stack pointer

Serial.print(F("RAM: SP-&gt;"));
printAddress(stackptr);
Serial.print(F(" HP-&gt;"));
printAddress(heapptr);//(int)&amp;__heap_start);
Serial.print(F(" FREE:"));
Serial.print(stackptr - heapptr);
Serial.println();
}


As a note, Comments are not mine.
Sure... if the RAM started at address 0, which it doesn't.

According to the datasheet the RAM starts at address 0x0100, below which are all the SFRs: