Is there a way to directly edit bits and bytes in SRAM?

I want to edit bits and bytes in SRAM, but I’m not sure how to do so. I need a method so that I can edit it so I can get the addresses (or whatever I need) after compiling from something like an SD card. I also need to read these bits and bytes after I edit them. I also don’t want to affect normal code from running if I do this, any ideas? I’ve tried researching but only found ways to create and delete blocks but not edit them.

yes. it is called a variable. sorry, I could not resist. try to explain better what you want to do

by SRAM, are you referring to PROGMEM? The portion of the flash memory where your code is stored?

If the “editing” has something to do with this:

project that runs scripts from an SD card

Then you would edit the character string that you have read in from the SD card.

That string’s address is of course available in the program that reads it in. Post that code.

I want to edit bits and bytes in SRAM, but I'm not sure how to do so.

That's pretty much the only thing that programs do.

You need to explain more precisely what you want to do. Perhaps you can provide an example?


Perhaps you mean how to directly access raw addresses?

  byte * address = (byte *) some_integer_address ;
  *address = some_function_of (*address) ;
  *address |= 0x04 ;
  *address &= ~0x80 ;

Stuff like that directly using an int for an address in SRAM?

Do you mean like with serial commands? Back around 2010, the Arduino MEGA bootloader used to have a monitor program you could activate by typing ‘!!!’ to the serial port. This was a problem because it even looked for the ‘!!!’ trigger while uploading sketches. If your sketch contained “!!!” in a string or any three bytes together with that ASCII value, it would cancel the upload and wait for serial commands. I don’t think modern MEGA bootloaders have that ‘feature’ anymore.

You could add such a feature to a sketch allowing you to read and modify whatever bytes in SRAM you want with commands from a serial port or even an I2C or SPI interface.