; GPIO Port 0 Register address, exercise 7a ; IO0DIR EQU 0xE0028008 IO0SET EQU 0xE0028004 IO0CLR EQU 0xE002800C IO0PIN EQU 0xE0028000 ; RED_LED EQU 0x00400000; p0.22=RED LED SW1 EQU 0x00100000; p0.20 as SW1 ; ;------------------------------------------------------------- ; User Initial Stack & Heap AREA |.text|, CODE, READONLY ;Question (a): When SW1 is depressed, ;When SW1 is depressed write the reg. values (R1,R2,R3,NZVC) ; after each line is executed ;Question (b):Repeat the above exercise when SW1 is not depressed EXPORT __main ;R0, R1, R3, NZVC __main ;line1 LDR R1, =RED_LED; p0.22 as output ;line2 LDR R0, =IO0DIR ;line3 STR R1,[R0]; ;line4 loop LDR R3, =IO0PIN; read SW1 (p0.22) ;line5 LDR R3, [R3] ;line6 TST R3, #SW1;if SW1 depressed R3=0 ;line7 BEQ onled ;if SW1 depressed LEDon ;line8 ; LDR R1, =RED_LED;otherwise LEDoff ;line9 LDR R0, =IO0CLR ;line10 STR R1,[R0] ;line11 B loop ;line12 onled;------ON LED--------- LDR R1, =RED_LED; on the LED ;line13 LDR R0, =IO0SET ;line14 STR R1,[R0] ;line15 B loop ;line16 END