上週我接受了採訪。我被要求寫一個宏來讀取一個內存位置(比如0x2000
)。 我在正常編程中編寫了代碼,但是我無法寫入宏。
請幫我弄清楚如何寫下面的代碼的宏:如何編寫一個宏來訪問C中的內存數據?
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