汇编: 操作LED灯(基于iTOP-4412)

基本操作流程可以参考:
https://blog.csdn.net/weixin_38184741/article/details/86368281
操作蜂鸣器可以参考:
https://blog.csdn.net/weixin_38184741/article/details/86618862

汇编代码:


.global _start
_start:

	bl uprintf

	bl led_init

loop:
	
	bl uprintf

	bl led2_on
	
	bl delay 

	bl led2_off

	bl delay
	
	bl led3_on
	
	bl delay 

	bl led3_off	
	
	bl delay 
	
	bl led2_on
	
	bl led3_on
	
	bl delay 
	
	bl delay 
	
	bl led3_off
	
	bl led2_off
	
	bl uprintf

	b loop

led_init:

	@LED2
	@KP_COL0  -> GPL2_0 
	@ 0x1100_0000 + 0x0100 = 0x11000100
	
	ldr r0, =0x11000100
	ldr r1, [r0]
	bic r1, r1, #0xf
	orr r1, r1, #0x1
	str r1, [r0]
	
	
	@LED3    ---P224
	@VDD50_EN  -> GPK1_1 
	@ 0x1100_0000 + 0x0060  = 0x11000060
	
	ldr r0, =0x11000060
	ldr r1, [r0]
	bic r1, r1, #(0xf << 4)
	orr r1, r1, #(0x1 << 4)
	str r1, [r0]
	
	mov pc, lr
	
	
led2_on:
	ldr r0, =0x11000104
	ldr r1, [r0]
		
	orr r1, r1, #0x1
	
	str r1, [r0]
	
	mov pc, lr
	
led3_on:
	ldr r0, =0x11000064
	ldr r1, [r0]
		
	orr r1, r1, #(0x1 << 1)
	
	str r1, [r0]
	
	mov pc, lr
	
	
led2_off:
	ldr r0, =0x11000104
	ldr r1, [r0]
	
	bic r1, r1, #0xf
	
	str r1, [r0]
	
	mov pc, lr
	
led3_off:
	ldr r0, =0x11000064
	ldr r1, [r0]
	
	bic r1, r1, #(0x1 << 1)
	
	str r1, [r0]
	
	mov pc, lr	
	
delay:
	mov r0, #0x10000000
	
d:
	subs r0, r0, #1
	bne d
	
	mov pc, lr
	
uprintf:
	ldr r0, =str
    mov r1, #222
    ldr pc, =0xc3e0d100
	
	mov pc, lr
	
str:
        .asciz "hello this is test = %d \n"

编译脚本:

arm-none-linux-gnueabi-gcc -c led.S -o led.o
arm-none-linux-gnueabi-ld -Ttext=0x40008000 led.o -o led
arm-none-linux-gnueabi-objcopy -O binary led led.bin

操作截图:

汇编: 操作LED灯(基于iTOP-4412)_第1张图片

你可能感兴趣的:(裸机,汇编)