51单片机汇编秒表程序

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

ORG 0000H

LJMP MAIN

ORG 0003H

LJMP INT_0

ORG 000BH

LJMP T0_INT

ORG 0013H

LJMP INT_1

ORG 001BH

LJMP T1_INT MAIN:

MOV TMOD,#11H

MOV TH1,#0D8H

MOV TL1,#0F0H

MOV TH0,#3CH

MOV TL0,#0B0H

SETB EA

SETB ET1

SETB ET0

SETB EX0

SETB EX1

SETB IT0

SETB IT1

SETB TR1

MOV 32H,#00H

MOV R1,#80H

MOV 30H,#00H LOOP:

MOV A,R4

CJNE A,33,Y

MOV A,R5

CJNE A,32H,Y

INC 30H

Y: MOV A,P3

CJNE A,#0CFH,Y1

LJMP Y2

Y1:

MOV A,30H

CJNE A,#01H,LOOP

CLR P1^0

LCALL DELAY2

SETB P1^0

LCALL DELAY2

LJMP LOOP

Y2:

JNB P3^5,Y2

JNB P3^4,Y2

MOV R3,#0AH

LJMP Y3

Y3: MOV R4,33H

MOV R5,32H

MOV A,P3

CJNE A,#0DFH,Y5

Y4:JNB P3^4,OUT

JNB P3^5,Y4

INC 32H

MOV A,32H

CJNE A,#10,Y3

INC 33H

MOV 32H,#00H

LJMP Y3

Y5:

MOV A,P3

CJNE A,#0EFH,Y3

Y6: JNB P3^5,OUT

JNB P3^4,Y6

MOV A,32H

CJNE A,#00,JJ

DEC 33H

MOV 32H,#09H

LJMP Y3

OUT:JNB P3^5,OUT

JNB P3^4,OUT

MOV R5,#00H

MOV R3,#00H

LJMP LOOP

JJ:

DEC 32H

LJMP Y3

INT_0:

CPL TR0

RETI

INT_1:

MOV R6,#00H

MOV R5,#00H

MOV R3,#00H

MOV R0,#00H

MOV 30H,#00H

T0_INT:

MOV TH0,#0D8H

MOV TL0,#0F0H

INC R0

CJNE R0,#0AH,T0_END

MOV R0,#00H

INC R6

CJNE R6,#0AH,T0_END

MOV R6,#00H

INC R5

CJNE R5,#0AH,T0_END

MOV R5,#00H

INC R4

CJNE R4,#0AH,T0_END

MOV R4,#00H

INC R3

CJNE R3,#0AH,T0_END

MOV R3,#00H

T0_END:RETI

T1_INT:

MOV TH1,#0D8H

MOV TL1,#0F0H

CJNE R1,#04H,NEXT1

MOV R1,#80H NEXT1:

CJNE R1,#80H,NEXT2

MOV P2,R1

MOV A,R6

MOV DPTR,#TAB

MOVC A,@A+DPTR

MOV P0,A

AJMP NEXT6 NEXT2:

CJNE R1,#40H,NEXT3

MOV P2,R1

MOV A,R5

MOV DPTR,#TAB

MOVC A,@A+DPTR

AJMP NEXT6

NEXT3:

CJNE R1,#20H,NEXT4

MOV P2,R1

MOV A,R4

MOV DPTR,#TAB

MOVC A,@A+DPTR

MOV P0,A

AJMP NEXT6 NEXT4:

CJNE R1,#10H,NEXT5

MOV P2,R1

MOV A,R3

MOV DPTR,#TAB

MOVC A,@A+DPTR

MOV P0,A

AJMP NEXT6 NEXT5:

CJNE R1,#08H,NEXT6

MOV P2,#40H

MOV P0,#7FH

AJMP NEXT6 NEXT6:

MOV A,R1

RR A

MOV R1,A

T1_END:RETI

DELAY2:MOV 7DH,#250

DEL11:DJNZ 7DH,DEL21

DEL21:NOP

NOP

NOP

NOP

NOP

NOP

NOP

MOV A,7DH

CJNE A,#00H,DEL11

RET

相关文档
最新文档