51單片機(jī)通用匯編延時(shí)子程序
[地址]:7FEBH - FFEBH
[功能]:延時(shí)
[入口]:延時(shí)常數(shù)放在 R2 寄存器中。時(shí)間常數(shù) N(十六進(jìn)制)所對(duì)應(yīng)的延時(shí)時(shí)間(6MZH 晶振時(shí))見下表:
[出口]:R2=0
[占用寄存器]:R2
[調(diào)用]:無
例:延時(shí)1 秒子程序
MOV R2,#18H
LCALL 7FEBH
RET
ORG 7FEBH ;通用延時(shí)子程序(07EBH 0FEBH ...)
L7FEB: PUSH 02H ;R2(復(fù)位后R2即為 02H)存放時(shí)間常數(shù),進(jìn)棧保護(hù)
L7FED: PUSH 02H ; R2 進(jìn)棧保護(hù)
L7FEF: PUSH 02H ; 進(jìn)棧
L7FF1: DJNZ R2,$ ;R2 不為零等待
POP 02H ;出棧
DJNZ R2,L7FEF ; R2 不為零轉(zhuǎn)
POP 02H ; 出棧
DJNZ R2,L7FED ; R2 不為零轉(zhuǎn)
POP 02H ; 出棧
DJNZ R2,L7FEB ; R2 不為零轉(zhuǎn)
RET ;子程序返回
END
N(十六進(jìn)制數(shù))T(機(jī)器周斯)T(秒) 子程序地址
1 11 0.000044
C 2728 0.010912
18 26323 0.105292 2800
1D 50838 0.203352 2808
21 80323 0.321292 2810
24 109666 0.438664 2818
26 133248 0.532992 2820
28 160431 0.641724 2828
29 175481 0.701024 2830
2E 267146 1.068584 2838
37 516836 2.067344 2840
3D 760366 3.041464 2848
42 1021681 4.086724 2850
46 1275016 5.100064 2858
54 2543878 10.175512 2860
65 5144436 20.577744 2868
70 7654053 30.616212 2870
78 9986491 39.945964 2878
7F 12432158 49.728632 2880
98 24956083 99.824332 2888
A9 37708623 150.83453
B6 50353668 201.41467 2890
CA 75697683 302.79073 2898
D9 100218410 400.87365 28A0
E6 125909940 503.63974 28A8
F1 151248830 605.03532 28B0
FF 188839490 755.35794
0 191768000 767.072 28B8
評(píng)論