声明:
这是
电子之城公布的一个
51开发板资料中看到的软延时子程序,由于时间太久远,原作者覃业宇先生的主页已经失效,现把原文件内容整理上来备用。
time10us: mov r5,#05h
djnz r5,$
ret
time50us: mov r5,#19h
djnz r5,$
ret
time100us: mov r5,#31h
djnz r5,$
ret
time200us: mov r5,#64h
djnz r5,$
ret
time250us: mov r5,#7ch
djnz r5,$
ret
time350us: mov r5,#0afh
time350us_1: djnz r5,time350us_1
ret
time500us: mov r5,#0fah
time500us_1: djnz r5,time500us_1
ret
time1ms: mov r5,#0fah
time1ms_1: nop
nop
djnz r5,time1ms_1
ret
time2_5ms: mov r5,#05h
time2_5ms_1: mov r6,#0f8h
djnz r6,$
djnz r5,time2_5ms_1
ret
time10ms: mov r5,#14h
time10ms_1: mov r6,#0ffh
djnz r6,$
djnz r5,time10ms_1
ret
time50ms: mov r5,#63h
time50ms_1: mov r6,#0fbh
djnz r6,$
djnz r5,time50ms_1
ret
time100ms: mov r5,#0c3h
time100ms_1: mov r6,#0ffh
djnz r6,$
djnz r5,time100ms_1
ret
time200ms: mov r5,#02h
time200ms_1: mov r6,#0f4h
time200ms_2: mov r7,#0ffh
djnz r7,$
djnz r6,time200ms_2
djnz r5,time200ms_1
ret
time500ms: mov r5,#04h
time500ms_1: mov r6,#0f4h
time500ms_2: mov r7,#0ffh
djnz r7,$
djnz r6,time500ms_2
djnz r5,time500ms_1
ret
time1s: mov r5,#08h
time1s_1: mov r6,#0f4h
time1s_2: mov r7,#0ffh
djnz r7,$
djnz r6,time1s_2
djnz r5,time1s_1
ret
评论