《趣味电子琴程序.doc》由会员分享,可在线阅读,更多相关《趣味电子琴程序.doc(6页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、趣味电子琴KEYBUF EQU 30HSTH0 EQU 31HSTL0 EQU 32HTEMP EQU 33H ORG 00H LJMP START ORG 0BH LJMP INT_T0START MOV TMOD,#01H SETB ET0 SETB EAWAIT MOV P3,#0FFH CLR P3.4 MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY1 LCALL DELY10MS MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY1 MOV A,P3 ANL A,#0FH CJNE A,#0EH,NK1 MOV KEYBUF
2、,#0 LJMP DK1NK1 CJNE A,#0DH,NK2 MOV KEYBUF,#1 LJMP DK1NK2 CJNE A,#0BH,NK3 MOV KEYBUF,#2 LJMP DK1NK3 CJNE A,#07H,NK4 MOV KEYBUF,#3 LJMP DK1NK4 NOPDK1 MOV A,KEYBUF MOV DPTR,#TABLE MOVC A,A+DPTR MOV P0,A MOV A,KEYBUF MOV B,#2 MUL AB MOV TEMP,A MOV DPTR,#TABLE1 MOVC A,A+DPTR MOV STH0,A MOV TH0,A INC TEM
3、P MOV A,TEMP MOVC A,A+DPTR MOV STL0,A MOV TL0,A SETB TR0DK1A MOV A,P3 ANL A,#0FH XRL A,#0FH JNZ DK1A SETB P1.2 CLR TR0NOKEY1 MOV P3,#0FFH CLR P3.5 MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY2 LCALL DELY10MS MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY2 MOV A,P3 ANL A,#0FH CJNE A,#0EH,NK5 MOV KEYBUF,#4 LJMP D
4、K2NK5 CJNE A,#0DH,NK6 MOV KEYBUF,#5 LJMP DK2NK6 CJNE A,#0BH,NK7 MOV KEYBUF,#6 LJMP DK2NK7 CJNE A,#07H,NK8 MOV KEYBUF,#7 LJMP DK2NK8 NOPDK2 MOV A,KEYBUF MOV DPTR,#TABLE MOVC A,A+DPTR MOV P0,A MOV A,KEYBUF MOV B,#2 MUL AB MOV TEMP,A MOV DPTR,#TABLE1 MOVC A,A+DPTR MOV STH0,A MOV TH0,A INC TEMP MOV A,TE
5、MP MOVC A,A+DPTR MOV STL0,A MOV TL0,A SETB TR0DK2A MOV A,P3 ANL A,#0FH XRL A,#0FH JNZ DK2A SETB P1.2 CLR TR0NOKEY2 MOV P3,#0FFH CLR P3.6 MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY3 LCALL DELY10MS MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY3 MOV A,P3 ANL A,#0FH CJNE A,#0EH,NK9 MOV KEYBUF,#8 LJMP DK3NK9 CJNE
6、 A,#0DH,NK10 MOV KEYBUF,#9 LJMP DK3NK10 CJNE A,#0BH,NK11 MOV KEYBUF,#10 LJMP DK3NK11 CJNE A,#07H,NK12 MOV KEYBUF,#11 LJMP DK3NK12 NOPDK3 MOV A,KEYBUF MOV DPTR,#TABLE MOVC A,A+DPTR MOV P0,A MOV A,KEYBUF MOV B,#2 MUL AB MOV TEMP,A MOV DPTR,#TABLE1 MOVC A,A+DPTR MOV STH0,A MOV TH0,A INC TEMP MOV A,TEMP
7、 MOVC A,A+DPTR MOV STL0,A MOV TL0,A SETB TR0DK3A MOV A,P3 ANL A,#0FH XRL A,#0FH JNZ DK3A SETB P1.2 CLR TR0NOKEY3 MOV P3,#0FFH CLR P3.7 MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY4 LCALL DELY10MS MOV A,P3 ANL A,#0FH XRL A,#0FH JZ NOKEY4 MOV A,P3 ANL A,#0FH CJNE A,#0EH,NK13 MOV KEYBUF,#12 LJMP DK4NK13 CJN
8、E A,#0DH,NK14 MOV KEYBUF,#13 LJMP DK4NK14 CJNE A,#0BH,NK15 MOV KEYBUF,#14 LJMP DK4NK15 CJNE A,#07H,NK16 MOV KEYBUF,#15 LJMP DK4NK16 NOPDK4 MOV A,KEYBUF MOV DPTR,#TABLE MOVC A,A+DPTR MOV P0,A MOV A,KEYBUF MOV B,#2 MUL AB MOV TEMP,A MOV DPTR,#TABLE1 MOVC A,A+DPTR MOV STH0,A MOV TH0,A INC TEMP MOV A,TE
9、MP MOVC A,A+DPTR MOV STL0,A MOV TL0,A SETB TR0DK4A MOV A,P3 ANL A,#0FH XRL A,#0FH JNZ DK4A SETB P1.2 CLR TR0NOKEY4 LJMP WAITDELY10MS MOV R6,#10D1 MOV R7,#248 DJNZ R7,$ DJNZ R6,D1 RETINT_T0 MOV TH0,STH0 MOV TL0,STL0 CPL P1.0 CPL P1.2 RETITABLE DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H DB 7FH,6FH,77H,7CH,39H,5EH,79H,71HTABLE1 DW 65110,65058,64684,65178,64968,65030,64580,65157,64777,64260,64400,64820,64021,64103,64524,64898 END
限制150内