热门关键字:  ubuntu  分区  函数  Fedora  linux系统进程

arm平台下 gcc汇编调用c函

来源: 作者: 时间:2008-03-06 Tag: 点击:
@******************************************************************************
@ File:init.s
@ 功能:通过它转入C程序
@******************************************************************************    
.text
.global _start
_start:
   ldr  sp, =1024*4 @设置堆栈,注意:不能大于4k,2410的nand只有前面4k映射到0地址
       @nand flash中的代码在复位后会移到内部ram中,此ram只有4k
   bl  main  @调用C程序中的main函数
halt_loop:
   b  halt_loop

@******************************************************************************
@ File:main.c
@ 功能:设置io口的电平
@******************************************************************************    
#define GPBCON  (*(volatile unsigned long *)0x56000010)
#define GPBDAT  (*(volatile unsigned long *)0x56000014)
int main()
{
 GPBCON  = 0x00004000;
 GPBDAT = 0x00000000;
 return 0;
}
@******************************************************************************
@ File:Makefile
@ 功能:编译,清除
@ arm-linux-ld -Ttext 0x0000000 -g  init.o main.o -o tmp.o  
@ arm-linux-gcc将生成elf格式的文件
@******************************************************************************
led: init.s  main.c
 arm-linux-gcc -g -c -o init.o
 arm-linux-gcc -g -c -o main.o main.c
 arm-linux-ld -Ttext 0x0000000 -g  init.o main.o -o tmp.o 
 arm-linux-objcopy -O binary -S tmp.o led
 
clean:
 rm -f   led
 rm -f   main.o
 rm -f   tmp.o
 rm -f   init.o

最新评论共有 4 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册