Saye 我有一个结构,设计成一套可随时改变的硬件登记册。
例如,
typedef struct
{
int register1;
char register2;
... (varying sizes, etc) ...
int registerX;
} registers_t;
And I m defining regs as a volatile pointer to the base of the
例如,
#define regs (* (volatile registers_t *) ADDR_OF_REGS)
我试图在某个特定时间倾倒垃圾场,将其从存放登记册历史的阵列中拯救出来。
例如,
registers_t register_history[5];
我的理解是,由于我的行为不明确,因此我可以 t/on,使动荡不安的* 趋于一致。
例如, I m trying to do something like the following:
memcpy(®ister_history[0], regs, sizeof(registers_t));
在不明确放弃和保存每个个人登记册的情况下,是否有任何办法复制登记?
Thank you for your help.
Edit:
Since I do not have sufficient reputation to answer my question until 8hrs after I posted, the question, I ll post the answer here for now:
Because I know that the registers will not change when I m trying to capture the data, I can cast the ADDR_OF_REGS to void * and use memcpy.
例如,
memcpy(®ister_history[0], (void *)ADDR_OF_REGS, sizeof(registers_t));