上周我接受了一次采访。我被要求编写一个宏来读取内存位置(比如0x2000
)。我在正常编程中编写了代码,但我无法编写宏。
请帮我弄清楚如何为下面的代码编写宏:
char *address = (char*)0x2000; // address is a pointer to address 3000 char val
*address = 36; // write 36 to 8 bit location at address
val = *address; // read 8 bit value from address