ORG 0000H
LJMP MAIN
ORG 000BH
LJMP T0ISR
ORG 0030H
MAIN:
MOV TMOD,#51H
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
MOV TH1,#0
MOV TL1,#0
SETB TR0
SETB TR1
SETB ET0
SETB EA
CLR A
MOV R2,#0
LOOP:
SJMP $
T0ISR:
CLR TR0
MOV TH0,#HIGH(65536-50000)
MOV TL0,#LOW(65536-50000)
SETB TR0
INC A
CJNE A,#20,T0E
MOV A,#0
INC R2
CJNE R2,#10,T0E
MOV R2,#0
MOV R1,TH1
MOV R0,TL1
MOV B,#10
LCALL DIV16
MOV P1,R0
T0E:
RETI
;R1:R0/B=R1:R0
DIV16:
MOV R7,#08H
MOV B,#6
DIV1:
CLR C
MOV A,R0
RLC A
MOV R0,A
MOV A,R1
RLC A
MOV R1,A
CLR C
SUBB A,B
JC DIV2
MOV R1,A
INC R7
DIV2:
DJNZ R7,DIV1
RET
END