C
69
inv
Guest on 2nd July 2022 04:34:11 PM
#include <avr/io.h>
#include <avr/pgmspace.h> // library to handle data in the program area
int strlen(char *); // just so the compiler doesn't issue warnings!
char mystring[] PROGMEM="ABCDEFGHI"; // define a C string in the program area
char buffer[20] __attribute__((section("*.noinit"))); // __attribute__((section("*.noinit"))); // when we don't want to initialize global variable;
register unsigned char temp asm("r2"); // did not change code size = 158 bytes
int main(){
char *i, *f;
strcpy_P(buffer, mystring); // copy string to RAM
i=buffer; // pointer to start of chain
f
= buffer
+ strlen(buffer
); //points to the end of the string + 1
while (i < f ){ // walk the vector while i < f
temp= *--f; // predecrement f, save last byte in temp
*f = *i; // put the value of the first in the last byte
*i++= temp; // now in the first I put the saved value and increment i
}
}