#include <LPC21xx.h>
#define LED_PIN 21 #define LED_OFF (IO0CLR=(1<<LED_PIN)) #define LED_ON (IO0SET=(1<<LED_PIN))
int main (void) { unsigned long i;
IO0DIR |= (1 << (LED_PIN)); for (i = 0; i < 6000000; i++); while(1) { LED_ON; for (i = 0; i < 6000000; i++); LED_OFF; for (i = 0; i < 6000000; i++); } }
以上是源程序,以下是Disassembly窗口的内容 239: Vectors LDR PC, Reset_Addr 0x00000000 E59FF018 LDR PC,[PC,#0x0018] 240: LDR PC, Undef_Addr 0x00000004 E59FF018 LDR PC,[PC,#0x0018] 241: LDR PC, SWI_Addr 0x00000008 E59FF018 LDR PC,[PC,#0x0018] 242: LDR PC, PAbt_Addr 0x0000000C E59FF018 LDR PC,[PC,#0x0018] 243: LDR PC, DAbt_Addr
。。。。。。。。//中间省略若干行。。。。。。。
13: IO0DIR |= (1 << (LED_PIN)); 0x000041C4 E59F1074 LDR R1,[PC,#0x0074] 0x000041C8 E5911008 LDR R1,[R1,#0x0008] 0x000041CC E3811602 ORR R1,R1,#0x00200000 0x000041D0 E59F2068 LDR R2,[PC,#0x0068] 0x000041D4 E5821008 STR R1,[R2,#0x0008] 14: for (i = 0; i < 6000000; i++); 0x000041D8 E3A00000 MOV R0,#0x00000000 0x000041DC EA000000 B 0x000041E4 0x000041E0 E2800001 ADD R0,R0,#0x00000001 0x000041E4 E59F1058 LDR R1,[PC,#0x0058] 0x000041E8 E1500001 CMP R0,R1 0x000041EC 3AFFFFFB BCC 0x000041E0 15: while(1) 16: { 0x000041F0 EA000011 B 0x0000423C 17: LED_ON; 0x000041F4 E3A01602 MOV R1,#0x00200000 0x000041F8 E59F2040 LDR R2,[PC,#0x0040] 0x000041FC E5821004 STR R1,[R2,#0x0004] 18: for (i = 0; i < 6000000; i++); 0x00004200 E3A00000 MOV R0,#0x00000000 0x00004204 EA000000 B 0x0000420C 0x00004208 E2800001 ADD R0,R0,#0x00000001 0x0000420C E59F1030 LDR R1,[PC,#0x0030] 0x00004210 E1500001 CMP R0,R1 0x00004214 3AFFFFFB BCC 0x00004208 |