如何在ARM代码warriror项目中调用c中的汇编代码?

时间:2021-09-20 03:14:20

I want to reset the PC pointer somewhere in my C code which probably requires some assembly functions.

我想在我的C代码中的某处重置PC指针,这可能需要一些汇编函数。

So I followed the instructions on the arm website and then:

所以我按照手臂网站上的说明进行操作,然后:

In one of .s files in my project, I added:

在我项目中的一个.s文件中,我添加了:

     PRESERVE8
     AREA    SCopy, CODE
     EXPORT reset 
   reset  
     LDR PC, #0                                             
     END

and then in one of my .c files, I did:

然后在我的一个.c文件中,我做了:

extern void reset();

and call the reset() function somewhere. However, I was always told the reset symbol can not be found. Did I miss something?

并在某处调用reset()函数。但是,我总是被告知无法找到重置符号。我错过了什么?

1 个解决方案

#1


3  

You can do it with pure C:

你可以用纯C做到这一点:

typedef void(*func)();
func reset = NULL;
reset();

#1


3  

You can do it with pure C:

你可以用纯C做到这一点:

typedef void(*func)();
func reset = NULL;
reset();