	.module delay.c
	.area text(rom, con, rel)
	.dbfile E:\刻录的\电子技术\项目\驱动程序\LCD1602四线接口应用范例\delay.c
	.dbfunc e delay_1ms _delay_1ms fV
;              i -> R16,R17
	.even
_delay_1ms::
	.dbline -1
	.dbline 5
; #include <iom8v.h>
; #include <macros.h>
; //8MHz时钟下
; void delay_1ms(void)//1ms延时函数
; {
	.dbline 7
;   unsigned int i;
;   asm("nop");
	nop
	.dbline 8
;   for (i=0;i<1139;i++)
	clr R16
	clr R17
	rjmp L5
L2:
	.dbline 9
	.dbline 10
L3:
	.dbline 8
	subi R16,255  ; offset = 1
	sbci R17,255
L5:
	.dbline 8
	cpi R16,115
	ldi R30,4
	cpc R17,R30
	brlo L2
	.dbline -2
L1:
	.dbline 0 ; func end
	ret
	.dbsym r i 16 i
	.dbend
	.dbfunc e delay_nms _delay_nms fV
;              i -> R20,R21
;              n -> R22,R23
	.even
_delay_nms::
	rcall push_gset2
	movw R22,R16
	.dbline -1
	.dbline 14
;   {  
;   } 
; }
; 
; void delay_nms(unsigned int n)//延时n毫秒
; {
	.dbline 16
;   unsigned int i;
;   for (i=0;i<n;i++)//执行n次1毫秒延时
	clr R20
	clr R21
	rjmp L10
L7:
	.dbline 17
	rcall _delay_1ms
L8:
	.dbline 16
	subi R20,255  ; offset = 1
	sbci R21,255
L10:
	.dbline 16
	cp R20,R22
	cpc R21,R23
	brlo L7
	.dbline -2
L6:
	rcall pop_gset2
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r n 22 i
	.dbend
	.dbfunc e delay_nus _delay_nus fV
;              i -> R20,R21
;              n -> R16,R17
	.even
_delay_nus::
	rcall push_gset1
	.dbline -1
	.dbline 21
;   delay_1ms(); 
; }
; 
; void delay_nus(unsigned int n)//延时N微秒,N>=5  晶振:8MHz
; {
	.dbline 23
;   unsigned int i;
;   for (i=5;i<n;i++)
	ldi R20,5
	ldi R21,0
	rjmp L15
L12:
	.dbline 24
	.dbline 25
	nop
	.dbline 26
	nop
	.dbline 27
L13:
	.dbline 23
	subi R20,255  ; offset = 1
	sbci R21,255
L15:
	.dbline 23
	cp R20,R16
	cpc R21,R17
	brlo L12
	.dbline -2
L11:
	rcall pop_gset1
	.dbline 0 ; func end
	ret
	.dbsym r i 20 i
	.dbsym r n 16 i
	.dbend
