ARM裸机开发入门(一)

一、常用汇编语言简单使用

1、ldr  加载数据

2、str  赋值(str r1,[r0]; 将r1中的值赋给r0)

3、bl   回调函数

4、add  按位加


二、点亮LED流水灯

    AREA Init, CODE ,READONLY
	ENTRY
	
start
    ;关闭看门狗
    ldr r0,=0x53000000
	ldr r1,=0
	str r1,[r0]
	
	ldr r0, = 0x56000000
	ldr r1, = 0
	str r1, [r0];设置GPA为输出
	
	ldr r0, = 0x56000010
	ldr r1, = 0x5 << 10 ;LED
;	add r1, 1 ;buzzer
	str r1, [r0];设置GPB为输出

	
	ldr r0, = 0x5600001c
	ldr r1, = 0x0
	str r1, [r0]
	
	
	
led_blink
    ;led on
	ldr r0, = 0x56000004
	ldr r1, = 0x2<<25
	str r1, [r0]
	
	bl delay;
	
	ldr r0, = 0x56000004
	ldr r1, = 1
	str r1, [r0];
	
	bl delay;
	
	ldr r0, = 0x56000004
	ldr r1, = 0x1<<25
	str r1, [r0];
	
	bl delay;
	
	ldr r0, = 0x56000004
	ldr r1, = 1
	str r1, [r0];
	
	bl delay;
	
	ldr r0, = 0x56000014
	ldr r1, = 0x2<<5
	str r1, [r0];
	
	bl delay;
	
	ldr r0, = 0x56000014
	ldr r1, = 1
	str r1, [r0];
	
	bl delay;
	
	ldr r0, = 0x56000014
	ldr r1, = 0x1<<5
	str r1, [r0];
	
	bl delay;
	
	ldr r0, = 0x56000014
	ldr r1, = 1
	str r1, [r0];

	bl delay
	
	bl led_blink

	
delay
    ldr r0, = 0x100000
delay_loop
    cmp r0,#0
    sub r0,r0,#1
	bne delay_loop
	mov pc ,lr
	
    END
	
	



你可能感兴趣的:(入门,学习笔记)