我正在使用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");
}
答案 0 :(得分:0)
您没有复制足够的字节数。你的记忆复制功能只复制6个字节,你想要6个整数吗?