 int SDReadInt (File file) {
   uint8_t b0 = file.read(); uint8_t b1 = file.read();
   return b0 | b1<<8;
+}
+#elif defined(FLASHWRITESIZE)
+uint8_t FlashReadByte (uint32_t *addr) {
+  return Flash.readByte((*addr)++);
+}
+
+int FlashReadInt (uint32_t *addr) {
+  int data = Flash.readWord(*addr);
+  (*addr)++; (*addr)++;
+  return data;
 }
 #else
 int EEPROMReadInt (unsigned int *addr) {

void SDWriteInt (File file, int data) {
  file.write(data & 0xFF); file.write(data>>8 & 0xFF);
}
#else
void EEPROMWriteInt (unsigned int *addr, int data) {
  EEPROM.write((*addr)++, data & 0xFF); EEPROM.write((*addr)++, data>>8 & 0xFF);

  }
  file.close();
  return imagesize;
#elif defined(FLASHWRITESIZE)
  if (!(arg == NULL || listp(arg))) error(SAVEIMAGE, invalidarg, arg);
  if (!FlashSetup()) error2(SAVEIMAGE, PSTR("no DataFlash found."));
  // Save to Flash
  int SymbolUsed = SymbolTop - SymbolTable;
  int bytesneeded = imagesize*4 + SymbolUsed + 10;
  if (bytesneeded > FLASHWRITESIZE) error(SAVEIMAGE, PSTR("image too large"), number(imagesize));
  if (!FlashBeginWrite(32)) error2(SAVEIMAGE, PSTR("problem erasing flash"));
  uint32_t addr = BASE_ADDRESS;
  FlashWriteInt(&addr, (uintptr_t)arg);
  FlashWriteInt(&addr, imagesize);
  FlashWriteInt(&addr, (uintptr_t)GlobalEnv);
  FlashWriteInt(&addr, (uintptr_t)GCStack);
  #if SYMBOLTABLESIZE > BUFFERSIZE
  FlashWriteInt(&addr, (uintptr_t)SymbolTop);
  for (int i=0; i<SymbolUsed; i++) FlashWriteByte(&addr, SymbolTable[i]);
  #endif
  for (unsigned int i=0; i<imagesize; i++) {
    object *obj = &Workspace[i];
    FlashWriteInt(&addr, (uintptr_t)car(obj));
    FlashWriteInt(&addr, (uintptr_t)cdr(obj));
  }
  return imagesize;
#else
  if (!(arg == NULL || listp(arg))) error(SAVEIMAGE, invalidarg, arg);
  int SymbolUsed = SymbolTop - SymbolTable;
