#include "GD.h"

int available()
{
    char stack = 1;
    Serial.print("stack=");
    Serial.println((int)&stack, HEX);
    extern char *__brkval;
    extern char *__malloc_heap_end;
    extern size_t __malloc_margin;
    if (__malloc_heap_end)
      return __malloc_heap_end - __brkval;
    return (&stack - __brkval) - __malloc_margin;
} 

byte foo[1000];

void setup()
{
  GD.begin();
  Serial.begin(115200);
  Serial.println("Hello");
  Serial.println(available(), DEC);
  Serial.println((unsigned int)foo, HEX);
  int i;
  for (i = 0; i < sizeof(foo); i++)
    foo[i] = i;
  Serial.println(foo[0], DEC);
  Serial.print("foo is at ");
  Serial.println((int)foo, HEX);
}

void loop()
{
}
