天天看點

ARM中彙編初始化GPIO

  • GPIO初始化
    ;init GPIO
     LDR r9, =0x90500000
     MOV r0, #0x0
     STR r0, [r9, #4]
     ;Write 0x55 to GPIO
     MOV r0, #0x55
     STR r0, [r9, #0x2c]
               
  • 将指定指令搬運到目标,目标位址在r10中,源指令在testinst sector中。
copystart
		nop
		
	LDR r12, =30
	LDR r7, =0

	ADR	r8,testinst
	mov 	r6, r10

copy_loop

	LDM  r8!, {r5}
	STR  r5, [r6]
	ADD  r6, r6, #4

	ADD r7, r7, #1
	CMP r7, r12
	NOP

	
	BLT copy_loop
	NOP
		nop
		nop
		nop
		nop
		nop
		nop

		MOV r0, #0x55
		STR r0, [r9, #0x2c]
		mov	pc,r10
		nop
		nop
		nop


           
  • 源sector位置
testinst

	DCD 0xe1a0800f    
	DCD 0xe3a000ff    
	DCD 0xe3800cff    
	DCD 0xe38008ff    
	DCD 0xe1c88000    
	DCD 0xe1a00008    
	DCD 0xe3800c02    
	DCD 0xe3a02412    
	DCD 0xe382270d    
	DCD 0xe3822c56    
	DCD 0xe3822078    
	DCD 0xe5802000    
	DCD 0xe1c020b4    
	DCD 0xe5c02008    
	DCD 0xe5901000    
	DCD 0xe1d020b4    
	DCD 0xe5d03008    
	DCD 0xe589102c    
	DCD 0xe1a01821    
	DCD 0xe589102c    
	DCD 0xe589202c    
	DCD 0xe589302c    
	DCD 0xe3a00055    
	DCD 0xe589002c    
	DCD 0xe1a0f000    
	DCD 0xe320f000    
	DCD 0xe320f000    
	DCD 0xe320f000