For low-level programming, sometimes it's necessary to say, at a given memory location, this is where my address is. For this post, the example is the PIR
register in the PIC16F886 and related microcontrollers. It's always found at address 0x000C.
I've taken this approach:
#define pir1 (*(uint8_t*)0xc)
now I can assign to the variable with something like pir1 |= 0x40
(okay, I'd use a #defined constant instead of magic numbers but you get my drift). This compiles just fine on GCC, with no warnings even when I use -Wextra -Wall
. To check my assumptions, GCC spits out the following x86_64:
movl $12,