networkyang 2013-04-29
开发环境:
系统:Ubuntu 10.04.4
单板:micro2440
编译器:arm-linux-gcc-4.3.2
目标:实现micro2440单板上4个led灯闪烁
第一个程序很简单,用汇编实现。硬件如下:
nLED_1——>GPB5
nLED_2——>GPB6
nLED_3——>GPB7
nLED_4——>GPB8
根据s3c2440手册编写代码,包括2个文件1_led.s和Makefile.
文件·1_led.s:
.text
.global _start
_start:
ldr r0,=0x56000010
mov r1,#0x00015400
str r1,[r0]
ldr r0,=0x56000014
loop: mov r1,#0x00000000
str r1,[r0]
bl delay
mov r1,#0x00000ff0
str r1,[r0]
bl delay
b loop
delay:
mov r4,#100
del1: mov r5,#1000
del2: sub r5,r5,#1
nop
cmp r5,#1
bne del2
sub r4,r4,#1
nop
cmp r4,#1
bne del1
mov pc,lr
文件Makefile:
1_led.bin:1_led.s
arm-linux-gcc -g -c -o 1_led.o 1_led.s
arm-linux-ld -Ttext 0x00000000 -g 1_led.o -o 1_led_elf
arm-linux-objcopy -O binary -S 1_led_elf 1_led.bin
arm-linux-objdump -D 1_led_elf > 1_led.dis
clean:
rm -f 1_led.bin *.o 1_led_elf 1_led.dis
linuxidc@linuxidc:~$ cd /home/linuxidc/Si/micro2440/1_led/
linuxidc@linuxidc:~/Si/micro2440/1_led$ make
arm-linux-gcc -g -c -o 1_led.o 1_led.s
arm-linux-ld -Ttext 0x00000000 -g 1_led.o -o 1_led_elf
arm-linux-objcopy -O binary -S 1_led_elf 1_led.bin
arm-linux-objdump -D 1_led_elf > 1_led.dis
linuxidc@linuxidc:~/Si/micro2440/1_led$ ls
1_led.bin 1_led.dis 1_led_elf 1_led.o 1_led.s Makefile