6410之写跳转到c函数中运行
来源:互联网 发布:北京java平均工资 编辑:程序博客网 时间:2024/05/17 05:05
汇编程序:
#define CONFIG_PERIPORT_BASE 0x70000000#define CONFIG_PERIPORT_SIZE 0x13#define WTCON 0x7E004000 .global _start_start:/*告诉CPU 外设的地址*/ldr r0, =CONFIG_PERIPORT_BASEorr r0, r0, #CONFIG_PERIPORT_SIZEmcr p15,0,r0,c15,c2,4/*关闭看门狗*/ldr r0, =WTCONmov r1, #1str r1,[r0]mov sp,#(1024*8) //设置栈,用来保存c函数的返回地址等等信息bl xxxx //跳转到c函数中执行halt:b halt
c程序:
#define GPMDAT (volatile unsigned long *)0x7F008824#define GPMCON (volatile unsigned long *)0x7F008820void delay(){volatile unsigned long i = 0x1000;while(i){i--;}}int xxxx(){volatile unsigned long *gpmcon = GPMCON;volatile unsigned long *gpmdat = GPMDAT;*gpmcon = 0x1111;int i = 0;while(1){*gpmdat = i;i++;if(i == 16)i = 0;delay();}return 0;}
在编译的时候会出现下面的错误:
arm-linux-gcc -c -o start.o start.S
arm-linux-gcc -c -o led.o led.c
arm-linux-ld -Ttext 0 -o led.elf start.o led.o
led.o:(.ARM.exidx+0x0): undefined reference to `__aeabi_unwind_cpp_pr0'
led.o:(.ARM.exidx+0x8): undefined reference to `__aeabi_unwind_cpp_pr1'
make: *** [led.bin] Error 1
解决方法如下:
led.o:led.c
arm-linux-gcc -nostdlib -c -o led.o led.c
start.o:start.S
arm-linux-gcc -nostdlib -c -o start.o start.S
在编译的选项中加入nostdlib 选项,不连接系统标准启动文件和标准库文件,只把指定的文件传递给连接器。这个选项常用于编译内核、bootloader等程序,它们不需要启动文件、标准库文件。
- 6410之写跳转到c函数中运行
- 6410之写跳转到c函数中运行
- 跳转到函数指针运行的地方,函数指针uboot中内容
- 避免tomcat运行过程中跳转到debug模式下
- Linux C写数据到文件中
- VS2010中跳转到此函数实现的快捷键
- C语言中实现跳转到任意行代码执行
- python中嵌入C运行时函数
- Android开发之--从app中跳转到淘宝店铺
- 和菜鸟一起学c之函数中堆栈及运行内存情况
- 和菜鸟一起学c之函数中堆栈及运行内存情况
- 和菜鸟一起学c之函数中堆栈及运行内存情况
- 将图片写到excel里的函数 c#.net
- 传递Lua函数到C/C++中
- linux C全局跳转函数
- C&C++函数内部跳转
- Mac写c、编译运行
- APP跳转到设置中
- IOS开发中的CGFloat、CGPoint、CGSize和CGRect
- 自动化测试框架思路
- 线性表练习题2-4
- Junit使用教程(三)
- 设计模式C++描述----10.装饰(Decorator)模式
- 6410之写跳转到c函数中运行
- Centos6.2_64位 服务器环境配置:源码编译Mysql
- 线性表练习题2-5
- Ajax注册验证
- jsp乱码处理
- 神经网络
- reference schematic
- C++库研究笔记——操作符重载实现类型转换&这样做的意义
- NSInvocation 的使用小例子