需要改另一个已经离职同事的程序,我没有学过单片机,只好请大家帮忙了.
要测电阻,因为方法修改,现在的测试数据应该是以前数据的10倍,因此之前的程序不用管,只需处理最后的显示了,例如以前显示212,现在显示2120.
大致看了一下,感觉应该是下面这一段,请各位大侠帮忙改一下:
;
; calculate one BCD code number(3 bytes, 6 bits) / 10
; entry @R0 is the high bit address
; result (BCD code, 3 bytes, 5 bits) save at old address
B3DIV10: MOV A,@R0
PUSH ACC
SWAP A
ANL A,#0FH
MOV @R0,A ; 10^4 bit
POP ACC
INC R0
XCHD A,@R0
PUSH ACC
MOV A,@R0
SWAP A
MOV @R0,A ; 10^3 and 10^2 bit
POP ACC
INC R0
XCHD A,@R0
MOV A,@R0
SWAP A
MOV @R0,A ; 10^1 and 10^0 bit
RET
;
; delay 10ms
DL10MS: PUSH ACC
MOV A,R6
PUSH ACC
MOV A,R7
PUSH ACC
MOV R6,#0AH
DL10: MOV R7,#0FAH
DJNZ R7,$
DJNZ R6,DL10
POP ACC
MOV R7,A
POP ACC
MOV R6,A
POP ACC
RET
;
; display result at numeral tube (LED)
DISPLAY: MOV TL0,#78H ; reset constant of 8031 timer 0
MOV TH0,#0ECH
PUSH PSW
PUSH ACC
MOV A,R6
PUSH A
PUSH ACC
MOV A,R7
PUSH ACC
PUSH DPH
PUSH DPL
MOV A,R1
PUSH ACC
MOV R1,#21H
MOV R6,#04H
MOV A,#00H ; close bit select, avoid shakeing
MOV DPTR,#0DFE3H ;
MOVX @DPTR,A
MOV A,#08H
SCAN: PUSH ACC
MOV DPTR,#0DFE3H ;
MOVX @DPTR,A
MOV DPTR,#HVCODE ; view code table, "1" is valid
MOV A,@R1
MOVC A,@A+DPTR
MOV DPTR,#0DFE1H ;
MOVX @DPTR,A
POP ACC
RR A
INC R1
MOV R7,#0FAH
DJNZ R7,$ ; delay 1ms
DJNZ R6,SCAN
MOV A,#00H ; close bit select
MOV DPTR,#0DFE3H
MOVX @DPTR,A
POP ACC
MOV R1,A
POP DPL
POP DPH
POP ACC
MOV R7,A
POP ACC
MOV R6,A
POP ACC
POP PSW
RETI
;
HVCODE: DB 3FH,06H,5BH,4FH,66H ;0---9
DB 6DH,7DH,07H,7FH,6FH
DB 0BFH,86H,0DBH,0CFH,0E6H ;0.---9.
DB 0EDH,0FDH,87H,0FFH,0EFH
DB 76H,38H,40H,00H ;"H","L","-",NONE
;
KOURCTAB: DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H
;
MOURCTAB: DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H,10H,00H,10H,00H,10H,00H,10H,00H
DB 10H,00H
END