【发布时间】:2018-02-15 10:40:37
【问题描述】:
我正在使用 STM32 QEMU 调试器来测试代码。我删除了 while(1),因为我只是测试了函数。
typedef int(*fnc_t) (int);
int multiply(int data) {
return (data * 5);
}
void memorycopy( unsigned char *src, unsigned char *dst, int size ) {
int j;
for( j=0; j < size; j++ ) {
dst[j] = src[j];
}
}
int main(int argc, char* argv[])
{
int i = 0;
unsigned int ram_vector[6];
fnc_t fnc_ram;
printf("1\n");
fnc_ram = (fnc_t) ( (int) &ram_vector + 1);
printf("2\n");
volatile int z = (int)( &multiply - 1);
memorycopy( (unsigned char*) z, (unsigned char*) fnc_ram, 6);
printf("3\n");
i = fnc_ram(3);
printf("4\n");
printf("Novo i: %d\n",i);
printf("5\n");
}
【问题讨论】:
-
为什么
&ram_vector + 1和为什么&multiply - 1为什么不只是 ram_vector 和乘法? -
因为处理器是ARM
-
arm 不需要 + 1,这在很多方面都是一个错误,或者用 1 表示,确保安全,但这只是意味着您使用的工具不正确。 cortex-ms 有一个向量表,而不是你刚开始执行的入口点,如果你想在 ram 中运行而不使用地址 0x00000000 向量表,那么对 ram 使用不同的引导程序......从 rom 复制并跳转。跨度>
-
你的qemu线路是什么?您在 qemu 中使用什么机器/目标?你想在哪里执行程序?
-
STM32F407VG,我不知道RAM在哪里,我认为是在MCU中。
标签: c eclipse embedded stm32 qemu