ORG 0000H
AJMP BEGIN
ORG 0030H
BEGIN:
MOV R0,#8
MAIN:
MOV A,R0
MOV R2,#00H
MOV SP,#60H
MOV R3,A
MOV R4,#16
MOV DPTR,#WORDTAB
START:
JNB P1.0,SLOW
JNB P1.1,SOON
MOV R1,#00H
SCAN8:
MOV A,R1
SWAP A
MOV P3,A
SWAP A
INC A
MOV R1,A
MOV A,R2
MOVC A,@A+DPTR
CJNE A, #0DDH,NEXT
AJMP MAIN
NEXT:
MOV P2,A
INC R2
MOV A,R2
MOVC 宴慧谨A,@A+DPTR
MOV P0,A
INC R2
LCALL DELAY1400
MOV P0,#00H
MOV P2,#00H
DJNZ R4,SCAN8
MOV R4,#16
DJNZ R3,SCAN16
AJMP 晌基END16
SCAN16:
MOV A,R2
CLR C
SUBB A,#32
MOV R2,A
AJMP START
END16:
INC DPTR
INC DPTR
MOV A,R2
CLR C
SUBB A,#32
MOV R2,A
MOV A,R0
MOV R3,A
AJMP START
SLOW:
LCALL DELAY20000
DEC R0
JB P1.0,$
AJMP BACK
SOON:
LCALL DELAY20000
INC R0
JB P1.1,$
AJMP BACK
BACK:
LCALL DELAY20000
AJMP START
DELAY1400: ;误差 0us
MOV R6,#7FH
DL0:
MOV R7,#04H
DJNZ R7,$
DJNZ R6,DL0
RET
DELAY20000: ;误差 0us
MOV R6,#0D7H
DL1:
MOV R7,#2DH
DJNZ R7,$
DJNZ R6,DL1
NOP
NOP
碧并 RET
WORDTAB:
DB 00H,1FH,80H,20H,40H,40H,20H,40H,10H,40H,08H,40H,04H,20H,02H,10H;
DB 02H,10H,04H,20H,08H,40H,10H,40H,20H,40H,40H,40H,80H,20H,00H,1FH;
TAB:;结束码
DB 0DDH
END
我也需要
好
不知道