[英]How to execute a function from RAM memory on STM32 QEMU debugger eclipse in C?
I'am using the STM32 QEMU debugger to test the code. 我正在使用STM32 QEMU调试器来测试代码。 I'm erase the while(1) because I just test the function.
我删除了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");
}
But when I call the function i = fnc_ram(3); 但是当我调用函数时,我= fnc_ram(3); the follow error occurs:
出现以下错误:
You're not copying enough bytes. 您没有复制足够的字节。 Your memorycopy function only copys 6 bytes and you want 6 integers don't you?
您的memorycopy函数仅复制6个字节,您想要6个整数吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.