czhxp:
好久不用汇编了,给个C51的例子参考一下吧#defineOUT0 P3_3#defineOUT1 P3_4#defineOUT2 P3_5#defineLea255/3voidmain(){ bitfagR,fagG,fagB; uchari,j; ucharx,y,z; uchartR,tG,tB; i=0; j=0;tR=rand();tR&=0x07;x=tR;tG=rand();tG&=0x07;y=tG;tB=rand();tB&=0x07;z=tB;iR=i;iG=iR+Lea;iB=iG+Lea;while(1){if(0==iR){tR=rand();tR&=0x07;x=tR;}if(0==iG){tG=rand();tG&=0x07;y=tG;}if(0==iB){tB=rand();tB&=0x07;z=tB;}do{if(iR>j)OUT0=1;else OUT0=0;if(iG>j)OUT1=1;else OUT1=0;if(iB>j)OUT2=1;else OUT2=0;}while(++j);if(x--==0){if(iR==0) fagR=0;elseif(iR==0xff)fagR=1;if(!fagR)iR++;else iR--;x=tR;if(iR