s5pv210 汇编开栈 C语言流水灯
作者:互联网
makefile
final.bin: start.o led.o arm-linux-ld -Ttext 0x0 -o start.elf $^ arm-linux-objcopy -O binary start.elf final.bin %.o : %.S arm-linux-gcc -o $@ $< -c -nostdlib //不连接系统标准启动文件和标准库文件,只把指定的文件传递给连接器 %.o : %.c arm-linux-gcc -o $@ $< -c -nostdlib clean: rm *.o *.elf *.bin -f
start.S
#define WTCON 0xE2700000 #define SVC_STACK 0xd0037d80 .global _start _start: // 第1步:关看门狗(向WTCON的bit5写入0即可) ldr r0, =WTCON ldr r1, =0x0 str r1, [r0] // 第2步:设置SVC栈 满减栈,满的意思是入栈先移动指针再填入数据,减的意思是栈从高到低用 ldr sp, =SVC_STACK // 第3步:开/关icache mrc p15,0,r0,c1,c0,0; // 读出cp15的c1到r0中 mrc和mcr是协处理器的相关汇编指令 //bic r0, r0, #(1<<12) // bit12 置0 关icache orr r0, r0, #(1<<12) // bit12 置1 开icache mcr p15,0,r0,c1,c0,0; bl led_blink //跳转到C语言函数 b .
led.c
#define GPJ0CON 0xE0200240 #define GPJ0DAT 0xE0200244 void delay(void) { unsigned int cnt = 900000; while(cnt) { cnt--; } } void led_blink(void) { unsigned int *p1 = (unsigned int *)GPJ0CON; unsigned int *p2 = (unsigned int *)GPJ0DAT; *p1 = 0x11111111; while(1) { *p2 = ~(1<<3); delay(); *p2 = ~(1<<4); delay(); *p2 = ~(1<<5); delay(); } }
标签:%.,r0,s5pv210,开栈,unsigned,C语言,start,int,linux 来源: https://www.cnblogs.com/hengqiu/p/15768714.html