PEEK and POKE into SRAM, how can it be done?


In the olden days when kids used to hack their C64 it was common to key in BASIC commands like PEEK and POKE to perform incredible actions.

You still can do it by manipulating pointers. But make sure to select memory addresses where nothing serious can happen.

void setup() {
  Serial.begin(9600);
  Serial.println("lies an Adresse 1000:");
  byte x = peek(1000);
  Serial.println(x);
  Serial.println("Schreibe neuen Wert an diese Adresse");
  poke(1000, x + 1);
  Serial.println("lies an Adresse 1000:");
  x = peek(1000);
  Serial.println(x);
  Serial.println("ready.");
}

void loop() {}

byte peek(void * x) {
  return *(byte*)x;
}

void poke(void *x, byte y) {
  *(byte*)x = y;
}



contact: nji(at)gmx.de