2.s

来自「arm汇编语言程序和其工具链的熟悉」· S 代码 · 共 49 行

S
49
字号

	AREA LED, CODE
	ENTRY

start
	ldr	r0, =0x03FF5000   ;after reset the start address of sfr is 0x3FF0000,0x5000 is the offset address of IOPMODE
	ldr	r1, =0x0003FFFF		; set all 18 gpios direction to output
	str	r1, [r0]					;
	
loop

; 
; hardware connection
; IO17 	IO04 	IO05 	IO06
; D6   	D7   	D8   	D9 
; so output value = 0x00000000 = (0b0000 0000  0000 0000  0000 0000  0000 0000)
;

	ldr	r1, =0x00		; show led = 0000	
	ldr	r0, =0x03FF5008	;0x5008 is the offset address of IOPDATA
	str	r1, [r0]

; delay for some time
	ldr	r1, =0x000FFFFF
delay1	
	sub	r1, r1, #1
	cmp 	r1, #0
	bne	delay1

; 
; hardware connection
; IO17 	IO04 	IO05 	IO06
; D6   	D7   	D8   	D9 
; so output value = 0x00020070 = (0b0000 0000  0000 0010  0000 0000  0111 0000)
; 
	ldr	r1, =0x00020070		; show led = 1111	
	ldr	r0, =0x03FF5008
	str	r1, [r0]

; delay for some time
	ldr	r1, =0x000FFFFF
delay2
	sub	r1, r1, #1
	cmp 	r1, #0
	bne	delay2
	
	B	loop
	
	END

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?