Reputation: 1727
In C, when I want to put number 5 at address 0x28, I can do it this way:
char* x = (char *) 0x28;
*x = 5;
If I want, I can do the same without declaring a variable:
*((char *) 0x28) = 5;
If I want that compiler treats this address as volatile, I can do it this way:
volatile char* x = (char *) 0x28;
*x = 5;
Can I do it without declaring a variable?
Edit: Let me explain why I want to do "*((char *) 0x28) = 5". I write a blinking LED hello world program for ATmega32U4 and I know that address 0x28 rules the pin to which my LED is connected. And it does work: the C code which you suggested compiles to correct machine code and the LED blinks.
Upvotes: 0
Views: 71