void waitkey(void) { uint32 i; uint32 b;
while(1) { if((IO0PIN&key1)==0);
else if((IO0PIN&key2)==0);
else if((IO0PIN&key3)==0);
else if((IO0PIN&key4)==0);
else if((IO0PIN&key5)==0);
else if((IO0PIN&key6)==0);
else goto loop;
for(i=0;i<5000;i++);
if((IO0PIN&key1)==0) {b=0; goto loop; }
else if((IO0PIN&key2)==0) {b=1; goto loop; }
else if((IO0PIN&key3)==0) {b=2; goto loop; }
else if((IO0PIN&key4)==0) {b=3; goto loop; }
else if((IO0PIN&key5)==0) {b=4; goto loop; }
else if((IO0PIN&key6)==0) {b=5; goto loop; }
}
loop: if(b==0) { while((IO0PIN&key1)==0); k=0; }
else if(b==1) { while((IO0PIN&key2)==0); k=2; }
else if(b==2) { while((IO0PIN&key3)==0); k=10; }
else if(b==3) { while((IO0PIN&key4)==0); k=18; }
else if(b==4) { while((IO0PIN&key5)==0); k=26; }
else if(b==5) { while((IO0PIN&key5)==0); k=34; }
}
大家看看这个程序,为什么每次运行到else if((IO0PIN&key6)==0);这句以后就不会运行后面的else goto loop; 而是跳到else if((IO0PIN&key6)==0) {b=5; goto loop; } ,然后我注释了if((IO0PIN&key1)==0);
//else if((IO0PIN&key2)==0);
//else if((IO0PIN&key3)==0);
//else if((IO0PIN&key4)==0);
//else if((IO0PIN&key5)==0);
//else if((IO0PIN&key6)==0);
else goto loop; 中的这些语句,程序还是跳转到else if((IO0PIN&key6)==0) {b=5; goto loop; }小弟向大家请教了 |