ORG 00H
MOV R6,#00
MOV R7,#16
START01:MOV A,#0FEH
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1 ;200ms
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#2.5,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#3.0,BJ3
BJ3: JC START02 ;第1路电压比较结束
START02:MOV A,#0FDH
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#0.45,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#0.6,BJ3
BJ3: JC START03 ;第2路电压比较结束
START03:MOV A,#0FBH
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#1.1,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#1.3,BJ3
BJ3: JC START04 ;第3路电压比较结束
START04:MOV A,#0F7H
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#0.65,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#1,BJ3
BJ3: JC START05 ;第4路电压比较结束
START05:MOV A,#0EFH
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#1.1,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#1.3,BJ3
BJ3: JC START06 ;第5路电压比较结束
START06:MOV A,#0DFH
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#0.45,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#0.6,BJ3
BJ3: JC START07 ;第6路电压比较结束
START07:MOV A,#0BFH
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#0.45,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#0.6,BJ3
BJ3: JC START08 ;第7路电压比较结束
START08:MOV A,#07FH
MOV P1,A
DJNZ R7,NO1
NO1: INC R6
MOV A,R6
ACALL DISP
ACALL YS1
MOVX @R0,A
WAIT: JB P3.5,ADC
JMP WAIT
ADC: MOVX A,@R0
DA A
CLR C
CJNE A,#0.31,BJ1
BJ1: JNC BJ2
BJ2: CJNE A,#0.35,BJ3
BJ3: JC ENDPRG ;第8路电压比较结束
ENDPRG:NOP
DISP: DA A
ANL A,#00FH
ORL A,#010H
MOV P3,A
ACALL YS2
ANL A,#0F0H
SWAP A
MOV P3,A
ACALL YS2
RET
YS1: MOV R3,#20 ;延时200ms
D1: MOV R4,#20
D2: MOV R5,#248
DJNZ R5,$
DJNZ R4,D2
DJNZ R3,D1
RET
YS2: MOV R3,#2 ;延时50ms
D1: MOV R4,#5
D2: MOV R5,#248
DJNZ R5,$
DJNZ R4,D2
DJNZ R3,D1
RET
END