RP2040编程:C与汇编交互及硬件直接访问
1. 从C调用汇编例程
在实际编程中,常见的做法是大部分应用程序用C语言编写,然后在特定用例中调用汇编语言例程。以调用 toupper 函数为例,由于C运行时已经存在 toupper 函数,为避免多重定义错误,将其重命名为 mytoupper ,并在C和汇编语言代码中都进行相应修改。
以下是调用汇编语言 mytoupper 函数的C代码示例( uppertst.c ):
//
// C program to call our Assembly Language
// toupper routine.
//
#include <stdio.h>
#include "pico/stdlib.h"
extern int mytoupper( char *, char * );
#define MAX_BUFFSIZE 255
void main()
{
char *str = "This is a test.";
char outBuf[MAX_BUFFSIZE];
int len;
stdio_init_all();
while( 1 )
{
len = mytoupper( str, outBuf );
printf("Before str: %s\n", str);
printf("After str: %s\n", outBuf
超级会员免费看
订阅专栏 解锁全文
3492

被折叠的 条评论
为什么被折叠?



