/******************************************************************************************************************
参考:
说明:这个是存到一个变量中,以后再补充一个返回值保存到指针中的。
******************************************************************************************************************/
- //startup.s
- AREA asmfile, CODE, READONLY
- EXPORT asmSum1
- IMPORT Main
- ENTRY
- START
- b Main
- asmSum1
- add r0, r0, r1
- over
- mov pc, lr
- END
- //main.c
- #include <stdio.h>
- extern int asmSum1(int src, int dest);
- int Main()
- {
- int s = 2;
- int d = 3;
- int c = asmSum1(s, d);
- //see c
- return 0;
- }
2.0 题目:设计一个函数,原型为 void asmSum1(int src, int dest, int *psum);在汇编中定义,并且通过psum指针接收结果;
- //main.c
- #include <stdio.h>
- extern int asmSum1(int src, int dest,int* san);
- int Main()
- {
- int s = 2;
- int d = 3;
- int psum[1];
- int c = (int)psum;
- asmSum1(s, d, psum);
- //see c
- return 0;
- }
- @@startup.s
- AREA asmfile, CODE, READONLY
- EXPORT asmSum1
- IMPORT Main
- ENTRY
- START
- b Main
- asmSum1
- add r0, r0, r1
- str r0, [r2]
- over
- mov pc, lr
- END
时间: 2024-10-21 04:24:06