标签:io ar sp on art bs ef linux tt
分别用汇编,汇编+C两种方式
***************************************
汇编编程led_on.s
****************************************
.text
.global _start
_start:
ldr ro,=0x*** //要操作的寄存器地址GPFCON
mov r1,#0x*** //要修改的寄存器值
str r1,[r0]
ldr ro,=0x*** //要操作的寄存器地址GPFDATE
mov r1,#0x*** //要修改的寄存器值
str r1,[r0]
main_loop:
b main_loop
***********************
makefile
led_on:led_on.s
arm_linux_gcc -g -c led_on.s -o led_on.o.
arm_linux_ld -Ttext 0x00000000 -g led_on.o -o led_on_elf
arm_inux_objcopy -o binary -S led_on.bin led_on_elf
clean:
rm -f led_on_elf led_on.bin *.o
******************************************
汇编和c混合编码crto.s led_on_c.c
******************************************
.text
.global _start
_start:
ldr ro,=0x53000000 //禁止看门狗
mov r1,#0x0
str r1,[r0]
ldr sp,=1024*4 //设置堆栈
bl main
main_loop:
b main_loop
*************************
#define GPFCON *** //需要操作的寄存器地址
#define GPFDAT ***
int main()
{
GPFCON=0x00000;
GPFDAT=0x10000;
return 0;
}
************************
makefile
led_on_c.bin : crt0.S led_on_c.c
arm-linux-gcc -g -c -o crt0.o crt0.S
arm-linux-gcc -g -c -o led_on_c.o led_on_c.c
arm-linux-ld -Ttext 0x0000000 -g crt0.o led_on_c.o -o led_on_c_elf
arm-linux-objcopy -O binary -S led_on_c_elf led_on_c.bin
arm-linux-objdump -D -m arm led_on_c_elf > led_on_c.dis
clean:
rm -f led_on_c.dis led_on_c.bin led_on_c_elf *.o
标签:io ar sp on art bs ef linux tt
原文地址:http://www.cnblogs.com/summer-xwq/p/4126786.html