一、思维导图
二、练习
实现三个灯闪烁
汇编代码
.text
.global _start
_start: @使能GPIOE和F时钟LDR r0,=0x50000A28LDR r1,[R0]ORR R1,R1,#(0X3<<4)STR R1,[R0]@配置GPIOE和F的MODER寄存器LDR r0,=0x50006000 @GPIOELDR R1,=0X50007000 @GPIOFLDR R2,[R0]BIC R2,R2,#(0X3<<20)BIC R2,R2,#(0X3<<16)ORR R2,R2,#(0X1<<20)ORR R2,R2,#(0X1<<16)STR R2,[R0]LDR R2,[R1]BIC R2,R2,#(0X3<<20)ORR R2,R2,#(0X1<<20)STR R2,[R1]@配置GPIOE和F的OTYPER寄存器LDR r0,=0x50006004 @GPIOELDR R1,=0X50007004 @GPIOFLDR R2,[R0]BIC R2,R2,#(0X1<<10)BIC R2,R2,#(0X1<<8)STR R2,[R0]LDR R2,[R1]BIC R2,R2,#(0X1<<10)STR R2,[R1]@配置GPIOE和F的OSPEEDR寄存器LDR r0,=0x50006008 @GPIOELDR R1,=0X50007008 @GPIOFLDR R2,[R0].text
.global _start
_start: @使能GPIOE和F时钟LDR r0,=0x50000A28LDR r1,[R0]ORR R1,R1,#(0X3<<4)STR R1,[R0]@配置GPIOE和F的MODER寄存器LDR r0,=0x50006000 @GPIOELDR R1,=0X50007000 @GPIOFLDR R2,[R0]BIC R2,R2,#(0X3<<20)BIC R2,R2,#(0X3<<16)ORR R2,R2,#(0X1<<20)ORR R2,R2,#(0X1<<16)STR R2,[R0]LDR R2,[R1]BIC R2,R2,#(0X3<<20)ORR R2,R2,#(0X1<<20)STR R2,[R1]@配置GPIOE和F的OTYPER寄存器LDR r0,=0x50006004 @GPIOELDR R1,=0X50007004 @GPIOFLDR R2,[R0]BIC R2,R2,#(0X1<<10)BIC R2,R2,#(0X1<<8)STR R2,[R0]BIC R2,R2,#(0X3<<20)BIC R2,R2,#(0X3<<16)STR R2,[R0]LDR R2,[R1]BIC R2,R2,#(0X3<<20)STR R2,[R1]@配置GPIOE和F的PUPDR寄存器LDR r0,=0x5000600C @GPIOELDR R1,=0X5000700C @GPIOFLDR R2,[R0]BIC R2,R2,#(0X3<<20)BIC R2,R2,#(0X3<<16)STR R2,[R0]LDR R2,[R1]BIC R2,R2,#(0X3<<20)STR R2,[R1]
LOOP:BL LED_ONBL DELAYBL LED_OFFBL DELAYB LOOPLED_ON:@GPIOELDR r0,=0x50006014LDR r1,[R0]ORR R1,R1,#(0X1<<10)ORR R1,R1,#(0X1<<8)STR R1,[R0]@GPIOFLDR r0,=0x50007014LDR r1,[R0]ORR R1,R1,#(0X1<<10)STR R1,[R0]MOV PC,LRLED_OFF:@GPIOELDR R0,=0x50006014LDR R1,[R0]BIC R1,R1,#(0X1<<10)BIC R1,R1,#(0X1<<8)STR R1,[R0]@GPIOFLDR r0,=0x50007014LDR r1,[R0]BIC R1,R1,#(0X1<<10)STR R1,[R0]MOV PC,LRDELAY:LDR R3,=0X10000000
MM:CMP R3,#0SUBNE R3,R3,#1BNE MMMOV PC,LR
.end
Makefile
NAME=asm-led
CROSS_COMPILE = arm-linux-gnueabihf-CC = $(CROSS_COMPILE)gccLD = $(CROSS_COMPILE)ld
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdumpall:$(CC) -O0 -g -c $(NAME).S -o $(NAME).o$(LD) -Ttext=0xC0008000 $(NAME).o -o $(NAME).elf $(OBJCOPY) -O binary $(NAME).elf $(NAME).bin$(OBJDUMP) -D $(NAME).elf > $(NAME).dis
clean:rm -rf *.elf *.bin *.o *.disinstall:sudo cp $(NAME).bin /mnt/hgfs/share/