ORG 0000H
LJMP MAIN
MAIN:
MOV 20H,#00H ;波形选择
MOV 21H,#00H ;幅度调节
MOV 22H,#01H ;频率调节
START:
LCALL READKEY ;读取键盘值
MOV A,20H
CJNE A,#00H,NEXT0
LCALL BOXING1
LJMP START
NEXT0:
MOV A,20H
CJNE A,#01H,NEXT1
LCALL BOXING2
LJMP START
NEXT1:
LCALL BOXING3
LJMP START
READKEY:
MOV A,P3
JNB ACC.2,SW1
JNB ACC.3,SW2
JNB ACC.4,SW3
JNB ACC.5,SW4
RET
SW1:LJMP F1
SW2:LJMP F2
SW3:LJMP F3
SW4:LJMP F4
F1: ;模式调节
INC 20H;
MOV A,20H;
CJNE A,#03H,DELAY
MOV A,#00H
MOV 20H,A
LJMP DELAY
F2: ;幅度调节
INC 21H;
MOV A,21H;
CJNE A,#0AH,DELAY
MOV A,#00H
MOV 21H,A
LJMP DELAY
F3: ;频率加
INC 22H;
MOV A,22H;
CJNE A,#0BH,DELAY
MOV A,#00H
MOV 22H,A
LJMP DELAY
F4: ;频率减
DEC 22H;
MOV A,22H;
CJNE A,#00H,DELAY
MOV A,#0AH
MOV 22H,A
LJMP DELAY
DELAY:
MOV 30H,#0FAH
MOV 31H,#0FAH
DLLP:
NOP
NOP
NOP
NOP
NOP
NOP
DJNZ 30H,DLLP
MOV 30H,#0FAH
DJNZ 31H,DLLP
LJMP READKEY
BOXING1:
MOV R1,#7FH
MOV R0,#00H
BO1:
MOV A,R0
MOV DPTR,#TABSIN
MOVC A,@A+DPTR
MOV P1,A
LCALL FREQ1
INC R0
DJNZ R1,BO1
RET
BOXING2:
MOV R1,#1FH
MOV R0,#00H
BO2:
MOV A,R0
MOV DPTR,#TABREC
MOVC A,@A+DPTR
MOV P1,A
LCALL FREQ2
INC R0
DJNZ R1,BO2
RET
BOXING3:
MOV R1,#3FH
MOV R0,#00H
BO3:
MOV A,R0
MOV DPTR,#TABTRI
MOVC A,@A+DPTR
MOV P1,A
LCALL FREQ2
INC R0
DJNZ R1,BO3
RET
TABTRI:
DB 0F7H,0F0H,0E7H,0E0H,0D7H,0D0H,0C7H,0C0H
DB 0B7H,0B0H,0A7H,0A0H,97H,90H,87H,80H
DB 77H,70H,67H,60H,57H,50H,47H,40H
DB 37H,30H,27H,20H,17H,10H,07H,00H
DB 07H,10H,17H,20H,27H,30H,37H,40H
DB 47H,50H,57H,60H,67H,70H,77H,80H
DB 87H,90H,97H,0A0H,0A7H,0B0H,0B7H,0C0H
DB 0C7H,0D0H,0D7H,0E0H,0E7H,0F0H,0F7H,0FFH
TABREC:
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH,0FFH
DB 00H,00H,00H,00H,00H,00H,00H,00H
DB 00H,00H,00H,00H,00H,00H,00H,00H
TABSIN:
DB 80H,86H,8DH,93H,99H,9FH,0A5H,0ABH
DB 0B1H,0B7H,0BCH,0C2H,0C7H,0CCH,0D1H,0D6H
DB 0DAH,0DFH,0E3H,0E7H,0EAH,0EEH,0F1H,0F4H
DB 0F6H,0F8H,0FAH,0FCH,0FDH,0FFH,0FFH,0FFH
DB 0FFH,0FFH,0FFH,0FEH,0FDH,0FBH,0F9H,0F7H
DB 0F5H,0F2H,0EFH,0ECH,0E9H,0E5H,0E1H,0DDH
DB 0D8H,0D4H,0CFH,0CAH,0C5H,0BFH,0BAH,0B4H
DB 0AEH,0A8H,0A2H,9CH,96H,90H,89H,83H
DB 80H,79H,72H,6CH,66H,60H,5AH,55H
DB 4EH,48H,43H,3DH,38H,33H,2EH,29H
DB 25H,20H,1CH,18H,15H,11H,0EH,0BH
DB 09H,07H,05H,03H,02H,00H,00H,00H
DB 00H,00H,00H,01H,02H,04H,06H,08H
DB 0AH,0DH,10H,13H,16H,1AH,1EH,22H
DB 27H,2BH,30H,35H,3AH,40H,45H,4CH
DB 51H,57H,5DH,63H,69H,6FH,76H,7CH
FREQ1:
MOV A,22H
MOV R7,A
D1:MOV B,#6FH
DJNZ B,$
DJNZ R7,D1
RET
FREQ2:
MOV A,22H
MOV R7,A
D2:MOV B,#1FH
DJNZ B,$
DJNZ R7,D2
RET
END
|