延时根据单片机调整.ORG 00HMOV P2,#80HSTART:MOV A,#0FFH ;赋初值 CLR C MOV R2,#8LOOP:RRC A ; 带进位右移 MOV P1,A CALL DELAY DJNZ R2,LOOP MOV R2,#7LOOP1:RLC A ; 带进位左移 MOV P1,A CALL DELAY DJNZ R2,LOOP1 JMP STARTDELAY:MOV R3,#20 ; 延时0.2秒D1: MOV R4,#20D2: MOV R5,#248 DJNZ R5,$ DJNZ R4,D2 DJNZ R3,D1 RET END
ORG 0030H MAIN: MOV P1,#01H ACALL DELAY MOV P1,#02H ACALL DELAY MOV P1,#04H ACALL DELAY MOV P1,#08H ACALL DELAY MOV P1,#10H ACALL DELAY MOV P1,#20H ACALL DELAY MOV P1,#40H ACALL DELAY MOV P1,#80H ACALL DELAY MOV P1,#80H ACALL DELAY MOV P1,#40H ACALL DELAY MOV P1,#20H ACALL DELAY MOV P1,#10H ACALL DELAY MOV P1,#08H ACALL DELAY MOV P1,#04H ACALL DELAY MOV P1,#02H ACALL DELAY MOV P1,#01H ACALL DELAY AJMP MAINDELAY: MOV R0,#250 D1: MOV R1,#250 DJNZ R1,$ DJNZ R0,D1 RET END这是当时学51的时候用的流水灯的程序,延时时间是乱定的,如果要精确地延时1s需要根据机器周期计算,修改delay函数中的数值就好了这个程序时赋值的,最简单易懂也最麻烦的,按照这个你可以试试左移右移指令的程序,会简单的多希望能有帮助