⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 intemp.asm

📁 智能计时计数器 有计两脉冲间隔时间、几脉冲间隔时间、30秒脉冲数等
💻 ASM
字号:
; interrup.asm generated from: interrup.c


NAME	INTEMP

?PR?int_0?INTEMP   SEGMENT CODE
?PR?int_1?INTEMP   SEGMENT CODE
?PR?TIME_0?INTEMP   SEGMENT CODE
?PR?TIME_1?INTEMP   SEGMENT CODE
?PR?START_00?INTEMP   SEGMENT CODE
?PR?START_11?INTEMP   SEGMENT CODE
	EXTRN   BIT (acce_chose)
        EXTRN   BIT (acce_id)
        EXTRN   BIT (time1_new)
	EXTRN	BIT (time2_new)
	EXTRN   BIT (star1_flat)
	EXTRN	BIT (star0_flat)
	EXTRN	BIT (over0_flat)
        EXTRN   BIT (over)
        EXTRN   DATA (select_id)
	EXTRN   DATA (time_tl0)
	EXTRN   DATA (time_tl1)
	EXTRN	DATA (n)
	EXTRN	DATA (n1)
        EXTRN   DATA (temp)
        EXTRN   DATA (time_hh)
        EXTRN   DATA (time1_hh)
        PUBLIC  START_11
        PUBLIC  START_00
        PUBLIC  TIME_1
        PUBLIC  TIME_0
	PUBLIC	int_1
	PUBLIC	int_0
CSEG	AT	00003H
	LJMP	int_0

; void int_0() interrupt 1 using 0

	RSEG  ?PR?int_0?INTEMP
	USING	3
int_0:   PUSH 	ACC             ;2
	PUSH 	PSW               ;2

        clr ie0                   ;1
	mov a,select_id             ;1
	cjne a,#11h,other_1          ;2
;deal with mode 1-1 ,
; start: set n=2 ,open  interrup 0(ex0),set time0 (th0,tl0),clear star_flat
;waiting: over_flat is 1
        jb star0_flat,read_11
         mov time_hh,#00
mov time_hh+1,#00
mov time_hh+2,#00
mov time_hh+3,#00
mov time_tl0,#00
mov tl0,#6
        clr tf0
        setb tr0
        setb star0_flat
	ljmp end_int0
read_11:
clr TR0
setb time1_new
clr star0_flat

end_11: ljmp  end_int0
other_1:	cjne a,#30h,other_2     ;2
;mode 1-1 over
mode_3:
;deal with mode 3-0,3-1,3-2,3-3
	clr ex1
	SETB 0CAH      ;setb TR2
        clr c
	mov a,#01h
	add a,n+01h
	mov n+01h,a
	clr a
        addc a,n
	mov n,a
	ljmp end_int0
other_2:cjne a,#31h,other_3       ;2
	ljmp   mode_3                ;2
other_3:cjne a,#32h,other_4         ;2
	ljmp mode_3
other_4:cjne a,#33h,other_0            ;2
	ljmp mode_3
;mode 3-0,3-1,3-2,3-3 over
;other mode
other_0:
        cjne a,#02h,other_00
	jb star0_flat,deal_with02         ;3
        clr tf0
 	setb tr0                          ;1
        setb star0_flat
	clr EX0                   ;1
	ljmp end_int0
deal_with02:                                    ;1
        clr tr0                              ;1
	mov dph,#00
	mov dpl,#04h
        ;mov dptr,#04h
        mov a,time_hh+1
        movx @dptr,a
        inc dptr
        mov a,time_hh+2
	movx @dptr,a
        inc dptr
	mov a,time_hh+3
	movx @dptr,a
        inc dptr
	mov a,tl0
	movx @dptr,a
        setb over
        ljmp end_int0

other_00:cjne a,#23h,other_000
	jb star0_flat,deal_with002         ;3
        clr tf0
 	setb tr0                          ;1
        setb star0_flat
	clr EX1                   ;1

	ljmp end_int0
deal_with002:
        mov a,n+1                            ;1

        cjne a,#3,deal_with
         clr EX0
         clr ie1
         setb EX1
        ljmp deal_with
other_000:jb star0_flat,deal_with         ;3
        clr tf0
 	setb tr0                          ;1
        setb star0_flat                   ;1
	ljmp end_int0

deal_with:

	mov r0,tl0                        ;2
        mov r1,time_hh+1                  ;2
        mov r2,time_hh+2                   ;2
        mov r3,time_hh+3                   ;2
        mov time_tl0,tl0                        ;2
        mov r5,time_hh+1                  ;2
        mov r6,time_hh+2                   ;2
        mov r7,time_hh+3                               ;1
        clr c
        mov a,r0

        cjne a,time_tl0,dodo1
        ljmp  save_data0
 dodo1:       ;tl0>new tl0  c=0
        jc save_data0
        clr c
        mov a,r7
        subb a,#1
        mov r3,a
        mov a,r6
        subb a,#00
        mov r2,a
        mov a,r5
        subb a,#00
        mov r1,a
save_data0:  mov a,n+1                        ;1
        mov b,#4                              ;2
        mul ab                                ;4
        mov dph,b                             ;2
        mov dpl,a                             ;2
        mov a,r1                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,r2                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,r3                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,r0                              ;1
        movx @dptr,a                          ;2
        mov a,n+1                            ;1
        dec a                                ;1
        mov n+1,a                            ;1
        cjne a,#0,end_int0                   ;2                            ;1
        clr tr0                              ;1
        setb over                            ;1
end_int0:
        POP 	PSW
        POP 	ACC
	RETI
; END OF int0



CSEG	AT	00013H
	LJMP	int_1

; void int_1() interrupt 3 using 2

	RSEG  ?PR?int_1?INTEMP
	USING	2
int_1:   PUSH 	ACC             ;2
	PUSH 	PSW               ;2

        clr ie1                   ;1
	mov a,select_id             ;1
	cjne a,#11h,other_b1          ;2
;deal with mode 1-1 ,
; start: set n=2 ,open  interrup 0(ex0),set time0 (th0,tl0),clear star_flat
;waiting: over_flat is 1
        jb star1_flat,read_b11
        mov time1_hh,#00
        mov time1_hh+1,#00
        mov time1_hh+2,#00
        mov time1_hh+3,#00
        mov time_tl1,#00
        mov tl1,#06h
        clr tf1
        setb tr1
        setb star1_flat
	ljmp end_b11
read_b11:
         clr TR1
         setb time2_new
                        ;2
again:
        clr star1_flat
set_over:
                           ;1
end_b11: ljmp  end_int1
other_b1:	cjne a,#30h,other_b2     ;2
;mode 1-1 over
mode_b3:
;deal with mode 3-0,3-1,3-2,3-3
	clr ex0
	SETB 0CAH
        clr c
	mov a,#01h
	add a,n+01h
	mov n+01h,a
	clr a
        addc a,n
	mov n,a
	ljmp end_int1
other_b2:cjne a,#31h,other_b3       ;2
	ljmp   mode_b3                ;2
other_b3:cjne a,#32h,other_b4         ;2
	ljmp mode_b3
other_b4:cjne a,#33h,other_11            ;2
	ljmp mode_b3
;mode 3-0,3-1,3-2,3-3 over
;other mode
other_11:


cjne a,#02h,other_b23
	jb star0_flat,deal_with12         ;3
        clr tf0
 	setb tr0                          ;1
        setb star0_flat
	clr EX1                   ;1
	ljmp end_int0
deal_with12:                                    ;1
        clr tr0                              ;1
        mov dph,#00h
       mov dpl,#04h
        ;mov dptr,#04h
        mov a,time_hh+1
        movx @dptr,a
        inc dptr
        mov a,time_hh+2
	movx @dptr,a
        inc dptr
	mov a,time_hh+3
	movx @dptr,a
        inc dptr
	mov a,tl0
	movx @dptr,a
        setb over
        ljmp end_int1

other_b23:
         cjne a,#23h,other_b
	jb star0_flat,deal_withb02         ;3
        clr tf0
 	setb tr0

        setb star0_flat
	clr EX0                   ;1
	ljmp end_int1
deal_withb02:

        mov a,n+1                            ;1
        cjne a,#3,deal_bwith
         clr EX1
         clr ie0
         setb EX0
        ljmp deal_bwith
other_b:
	jb star0_flat,deal_bwith         ;3
        clr tf0
 	setb tr0                          ;1
        setb star0_flat                   ;1
	ljmp end_int1
deal_bwith:

	mov r0,tl0                        ;2
        mov r1,time_hh+1                  ;2
        mov r2,time_hh+2                   ;2
        mov r3,time_hh+3                   ;2
         mov time_tl0,tl0                        ;2
        mov r5,time_hh+1                  ;2
        mov r6,time_hh+2                   ;2
        mov r7,time_hh+3                               ;1
        clr c
        mov a,r0

        cjne a,time_tl0,dodo
        ljmp  save_data
        ;tl0>new tl0  c=0
 dodo:       jc save_data
        clr c
        mov a,r7
        subb a,#1
        mov r3,a
        mov a,r6
        subb a,#00
        mov r2,a
        mov a,r5
        subb a,#00
        mov r1,a
save_data:  mov a,n+1                        ;1
        mov b,#4                              ;2
        mul ab                                ;4
        mov dph,b                             ;2
        mov dpl,a                             ;2
        mov a,r1                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,r2                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,r3                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,r0                              ;1
        movx @dptr,a                          ;2
        mov a,n+1                            ;1
        dec a                                ;1
        mov n+1,a                            ;1
        cjne a,#0,end_int1                   ;2                             ;1
        clr tr0                              ;1
        setb over                            ;1
end_int1:
        POP 	PSW
        POP 	ACC
	RETI
; END OF int1

; void time_0() interrupt 2 using 1
CSEG	AT	0000BH
	LJMP	TIME_0
	RSEG  ?PR?TIME_0?INTEMP
	USING	1
TIME_0:
        PUSH 	ACC
	PUSH 	PSW
        CLR TF0
        CLR C
	mov a,select_id
	cjne a ,#11h,time0_set
        setb PT1
time0_set:    MOV a,time_hh+3
        ADD a,#1
        mov time_hh+3,a
        mov a,time_hh+2
        addc a,#00
        mov time_hh+2,a
        mov a,time_hh+1
        addc a,#00
        mov time_hh+1,a
        mov a,time_hh
        addc a,#00
        mov time_hh,a
        clr c
        POP 	PSW
        POP 	ACC
	RETI
 ;end time_0
 ; void time_1() interrupt 4 using 1
 CSEG	AT	0001BH
	LJMP	TIME_1
	RSEG  ?PR?TIME_1?INTEMP
	USING	1
TIME_1:
        PUSH 	ACC
	PUSH 	PSW
        CLR TF1
        CLR C
	mov a,select_id
	cjne a ,#11h,time1_set
        setb PT0
time1_set:  MOV a,time1_hh+3
        ADD a,#1
        mov time1_hh+3,a
        mov a,time1_hh+2
        addc a,#00
        mov time1_hh+2,a
        mov a,time1_hh+1
        addc a,#00
        mov time1_hh+1,a
        mov a,time1_hh
        addc a,#00
        mov time1_hh,a
        clr c
        POP 	PSW
        POP 	ACC
	RETI
 ;end time_1
 ;void start_00(void)
 RSEG  ?PR?START_00?INTEMP
START_00:
        PUSH DPL
	PUSH DPH
         clr star0_flat
         mov  time_tl0,#00
         clr over
         mov time_hh,#00
         mov time_hh+1,#00
         mov time_hh+2,#00
         mov time_hh+3,#00
         mov TMOD,#02h
         mov th0,#06h
         mov tl0,#06h
         mov TCON,#00h
         setb PT0
         clr TF0
         clr PX0
         clr PX1
         setb IT0
         setb IT1
         clr IE1
         clr IE0
         setb EA
         setb ET0
	 jnb acce_chose,all_set
         jb acce_id,set_ex
         setb EX0
         clr EX1
         ljmp set_12over
set_ex:  setb EX1
         clr EX0
	 jmp set_12over
all_set:
         setb EX0
	 setb EX1
set_12over: nop
lll:
        jb over,out00
        jb P1.3,lll
out00:
        clr P1.2;test
        clr EA
        clr TR0
        clr EX0
        clr EX1
        clr ET0
aaa:
        jnb P1.3,aaa
        POP DPH
        POP DPL
        ret
;end start_00
;void start_11(void)
RSEG  ?PR?START_11?INTEMP
START_11:
        PUSH DPL
	PUSH DPH
         clr star0_flat
         clr star1_flat
         clr over
         clr over0_flat
         mov TMOD,#22h
         mov th0,#6
         mov th1,#06h
         mov TCON,#00h
         clr TF0
         clr TF1
         setb PT0
         clr PT1
         clr PX0
         clr PX1
         setb IT0
         setb IT1
         clr IE1
         clr IE0
         setb EA
         setb ET1
         setb ET0
         setb EX0
         setb EX1
        ;setb P1.2     ;test
lll11:   jnb time1_new,kkt
         clr time1_new
        mov a,n+1                        ;1
        mov b,#4                              ;2
        mul ab                                ;4
        mov dph,b                             ;2
        mov dpl,a                             ;2
        mov a,time_hh+1                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,time_hh+2                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,time_hh+3                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,TL0                              ;1
        movx @dptr,a                        ;2
         mov a,n+1                            ;1
        dec a                                ;1
        mov n+1,a                            ;1
        cjne a,#0,kkt                   ;2
        setb over0_flat
        clr EX0
kkt:         jnb time2_new,kktt
           clr time2_new
         mov a,n1+1                        ;1
        mov b,#4                              ;2
        mul ab                                ;4
        add a,#8
        mov dph,b                             ;2
        mov dpl,a                             ;2
        mov a,time1_hh+1                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,time1_hh+2                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,time1_hh+3                              ;1
        movx @dptr,a                          ;2
        inc dptr                              ;1
        mov a,tl1                              ;1
        movx @dptr,a
         mov a,n1+1                            ;1
        dec a                                ;1
        mov n1+1,a                            ;1
        cjne a,#0,kktt                   ;2
        setb over
        clr EX1
kktt:         jnb P1.3,out11
         jnb over,lll11
         jnb over0_flat,lll11
out11:
         clr EA
         clr TR0
         clr EX0
         clr EX1
         clr ET0
aaa11:
         jnb P1.3,aaa11
         POP DPH
         POP DPL
         ret
 ;end start_11
	 END

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -