如下面得一段程序,汇编实现起来挺容易得,但是想用c51去改如何写啊,才能更好得优化呢 各位高手看看啊 谢谢!
关键是如何实现 延时得同时还要判断,然后跳转,大家看看啊 谢谢~!
GAINWAITY: MOV R1,#0ffH MOV R2,#0ffH MOV R3,#10 GAINWAITAY: MOVX A,@DPTR RR A RR A ANL A,#03H CJNE A,#01H,NGAINWAITAY ;01 不等于01则继续执行 jb gainbitY,gainwaita0Y DJNZ R1,GAINWAITAY MOV R1,#255 DJNZ R2,GAINWAITAY mov r2,#0ffh djnz r3,gainwaitaY setb gainbitY CLR EX0 gainwaita0Y: clr gainbitY LJMP LOOP ;等于01则等待
GAINJUDGE2Y1:
NGAINWAITAY: MOV R1,#0ffH MOV R2,#0ffH mov r3,#10 GAINJUDGE1Y: clr gainbitY MOVX A,@DPTR RR A RR A ANL A,#03H CJNE A,#00H,GAINJUDGE2Y1 ;00 不等于00则继续执行 jb gainbitY,gainwaita0Y DJNZ R1,GAINJUDGE1Y MOV R1,#255 DJNZ R2,GAINJUDGE1Y mov r2,#0ffh djnz r3,GAINJUDGE1Y setb gainbitY CLR EX0 LJMP LOOP |