void main(void){ unsigned int a; unsigned char b,i,j=0x7f; while(1) { b=a>>8; for(i=0;i<8;i++) { if(b&j)b|=1< else b&=~(1< j=(j>>1)|(j<<7); } P0=a; P2=b; a++; delay(); }}写的有点麻烦。。。目前我只能想到这样