返回列表 发帖

功能齐全的单片机音乐程序

单片机最小系统,两位LED数码管由串口输出接两个164驱动,Lout,Rout为左右声道输出,
SET,  ALT0, ALT1为三个按键,也可自己在开始的I/O定义改成你想用的I/O口;12M晶振
若用89C51则只可装下约14首歌曲,用89C52则可装下近40曲
  1. ; Electronic Music
  2. ; Version 4.50
  3. ; Copyright (c) XAJ 2001
  4. ;============================
  5. LOUT BIT P1.0 ;左声道输出
  6. ROUT BIT P1.2 ;右声道输出
  7. SET BIT P3.3 ;SET按键
  8. ALT0 BIT P3.6 ;ALT0按键
  9. ALT1 BIT P3.7 ;ALT1按键

  10. ;REPNUM EQU 09H重复段编号
  11. STATU EQU 0AH;状态寄存器
  12. LDYDSR EQU 0BH;左低音度数
  13. RDYDSR EQU 0CH;右低音度数
  14. LDYAR EQU 0DH;左低音协助
  15. RDYAR EQU 0EH;右低音协助
  16. JPCLK EQU 0FH;节拍时钟
  17. GENCLK EQU 10H;通用时钟
  18. SNSDCLK EQU 11H;搜、存显示时钟
  19. GEN16T0 EQU 12H;通用16位时钟
  20. GEN16T1 EQU 13H;
  21. SETST0 EQU 14H;设置状态
  22. SETST1 EQU 15H; 定时时钟
  23. DISNUM0 EQU 16H;显示数值
  24. DISNUM1 EQU 17H;寄存器(2位)
  25. CSN EQU 18H;当前曲曲号
  26. REP0L EQU 19H;0号重复段地址
  27. REP0H EQU 1AH;
  28. REP1L EQU 1BH;1号重复段地址
  29. REP1H EQU 1CH;
  30. REP2L EQU 1DH;2号重复段地址
  31. REP2H EQU 1EH
  32. REP3L EQU 1FH;3号重复段地址
  33. REP3H EQU 23H;
  34. COSPEEDN EQU 24H;
  35. SPENR EQU 25H;

  36. LOCF BIT 00H;左声道开关标志
  37. ROCF BIT 01H;右声道开关标志
  38. SECHSTOF BIT 02H;搜索、存储标志
  39. NEXTSF BIT 03H;下一曲标志
  40. CSBESTOF BIT 04H;当前曲锁存/释放
  41. CUYFD BIT 05H;当前音符显示
  42. KSETF BIT 06H;SET键按下标志
  43. KALT0F BIT 07H;ALT0键按下标志
  44. KALT1F BIT 08H;ALT1键按下标志
  45. SPEEDF BIT 09H;速度增/减标志
  46. TONEF BIT 0AH;音调增/减标志
  47. YPBIT BIT 0BH;音频逻辑输出
  48. KBDISF BIT 0CH;键盘显示标志
  49. REP0F BIT 0DH;0号重复段控制
  50. REP1F BIT 0EH;1号重复段控制
  51. REP2F BIT 0FH;2号重复段控制
  52. REP3F BIT 10H;3号重复段控制

  53. SBOTM EQU 25H;堆栈区(栈底)
  54. BUFF0 EQU 43H;锁存曲数
  55. BUFF EQU 44H;锁存曲缓冲区
  56. ;============================

  57. ;=========BEGIN==============
  58. ORG 0000H
  59. LJMP MAIN
  60. ;---------T0INT--------------
  61. ORG 000BH
  62. LJMP T0INT

  63. ;---------T1INT--------------
  64. ORG 001BH
  65. LJMP T1INT
  66. ;1.音频发生器
  67. ;---------YPFSQ(01)----------
  68. ORG 0030H
  69. T0INT: MOV TL0,R4
  70. MOV TH0,R5
  71. PUSH PSW
  72. PUSH ACC
  73. PUSH 01H
  74. JB LOCF,ROPER
  75. MOV R1,#00H
  76. MOV A,LDYAR
  77. T0LLOP: RRC A
  78. MOV YPBIT,C
  79. XCH A,R1
  80. CJNE A,LDYDSR,T0LNEXT
  81. MOV C,YPBIT
  82. MOV LOUT,C
  83. INC LDYAR
  84. ; INC P0
  85. SJMP ROPER
  86. T0LNEXT: XCH A,R1
  87. INC R1
  88. SJMP T0LLOP
  89. ROPER: JB ROCF,T0RETI
  90. MOV R1,#00H
  91. MOV A,RDYAR
  92. T0RLOP: RRC A
  93. MOV YPBIT,C
  94. XCH A,R1
  95. CJNE A,RDYDSR,T0RNEXT
  96. MOV C,YPBIT
  97. MOV ROUT,C
  98. INC RDYAR
  99. ; INC P2
  100. SJMP T0RETI
  101. T0RNEXT: XCH A,R1
  102. INC R1
  103. SJMP T0RLOP
  104. T0RETI: POP 01H
  105. POP ACC
  106. POP PSW
  107. RETI
  108. ;2.通用时钟
  109. ;---------CLOCK(02)----------
  110. T1INT: MOV TL1,#0F0H
  111. MOV TH1,#0D8H
  112. PUSH PSW
  113. PUSH ACC
  114. INC JPCLK
  115. INC GENCLK
  116. INC SNSDCLK
  117. MOV A,SNSDCLK
  118. CJNE A,#0FFH,T1NEXT
  119. CLR SECHSTOF
  120. T1NEXT: INC GEN16T0
  121. MOV A,GEN16T0
  122. CJNE A,#100,T1NEXT0
  123. MOV GEN16T0,#00H
  124. INC GEN16T1
  125. T1NEXT0: INC SETST0
  126. MOV A,SETST0
  127. CJNE A,#100,T1RETI
  128. MOV SETST0,#00H
  129. INC SETST1
  130. MOV A,SETST1
  131. CJNE A,#20,T1RETI
  132. MOV SETST1,#00H
  133. MOV STATU,#00H
  134. T1RETI: POP ACC
  135. POP PSW
  136. RETI
  137. ;3.显示子程序
  138. ;---------DISPLAY(03)--------
  139. DISPLAY: PUSH ACC
  140. PUSH DPL
  141. PUSH DPH
  142. MOV DPTR,#T_FIGCODE
  143. MOV A,DISNUM0
  144. MOVC A,@A+DPTR
  145. MOV SBUF,A
  146. JNB TI,$
  147. CLR TI
  148. MOV A,DISNUM1
  149. MOVC A,@A+DPTR
  150. MOV SBUF,A
  151. JNB TI,$
  152. CLR TI
  153. POP DPH
  154. POP DPL
  155. POP ACC
  156. RET
  157. T_FIGCODE:
  158. DB 088H,0EBH,04CH,049H
  159. ; 0 1 2 3
  160. DB 02BH,019H,018H,0CBH
  161. ; 4 5 6 7
  162. DB 008H,009H,00AH,038H
  163. ; 8 9 A B
  164. DB 09CH,068H,01CH,01EH
  165. ; C D E F
  166. DB 080H,0E3H,044H,041H
  167. ; 0. 1. 2. 3.
  168. DB 023H,011H,010H,0C3H
  169. ; 4. 5. 6. 7.
  170. DB 000H,001H,002H,030H
  171. ; 8. 9. A. B.
  172. DB 094H,060H,014H,016H
  173. ; C. D. E. F.
  174. DB 0FFH,02FH,098H,07FH
  175. ; 熄灭 # G -
  176. DB 07CH,078H,0BCH,00AH
  177. ; c o L R
  178. DB 029H
  179. ; Y
  180. ;4.主程序MAIN
  181. ;---------MAIN(04)-----------
  182. MAIN: MOV R0,#01H
  183. CLR A
  184. CLRAM: MOV @R0,A
  185. INC R0
  186. CJNE R0,#80H,CLRAM
  187. MOV R0,A
  188. MOV SP,#SBOTM
  189. MOV 08H,#BUFF
  190. ;MOV 09H,#BUFF
  191. MOV SCON,#00H
  192. MOV TMOD,#11H
  193. MOV TL1,#0F0H
  194. MOV TH1,#0D8H
  195. SETB EA
  196. SETB ET0
  197. SETB ET1
  198. SETB TR1

  199. START: MOV DPTR,#T_SONGS
  200. RYF: LCALL RYFSUP
  201. MOV A,R7
  202. JZ START
  203. CJNE R7,#0FFH,SYF
  204. JBC NEXTSF,NEXTSCL
  205. MOV A,STATU
  206. JNZ GONSBQ
  207. MOV A,BUFF0
  208. JNZ MPSQCL
  209. LCALL PAQSCL
  210. SJMP MQNFD
  211. MPSQCL: LCALL PSQSCL
  212. MQNFD: LCALL QNFDSUP
  213. MOVPJRYF: INC DPTR
  214. INC DPTR
  215. SJMP RYF
  216. NEXTSCL: LCALL CSBESTOJG
  217. JB CSBESTOF,CALLPSCL
  218. LCALL PAQSCL
  219. SJMP MOVPJRYF
  220. CALLPSCL: LCALL PSQSCL
  221. SJMP MOVPJRYF
  222. GONSBQ: LCALL CSDPTR
  223. INC DPTR
  224. INC DPTR
  225. SJMP MOVPJRYF
  226. SYF: CJNE R6,#0FFH,CALLPLAY
  227. LCALL REPCLSUP
  228. SJMP MOVPJRYF
  229. CALLPLAY: LCALL YFDSUP
  230. LCALL PLAY
  231. SJMP MOVPJRYF
  232. ;5.读音符子程序
  233. ;---------RYFSUP(05)--------
  234. RYFSUP: CLR A
  235. MOVC A,@A+DPTR
  236. MOV R6,A
  237. MOV A,#01H
  238. MOVC A,@A+DPTR
  239. MOV R7,A
  240. RET
  241. ;6.统唱曲首处理
  242. ;---------PAQSCL(06)--------
  243. PAQSCL: MOV CSN,R6
  244. INC DPTR
  245. INC DPTR
  246. LCALL RYFSUP
  247. MOV 02H,R6
  248. MOV 03H,R7
  249. RET
  250. ;7.存唱曲首处理
  251. ;---------PSQSCL(07)--------
  252. PSQSCL: PUSH PSW
  253. SETB RS0
  254. CLR RS1
  255. PSQC7E: CJNE R0,#7EH,PSQNEXT
  256. PSQNEXT: JC PSQNEXT1
  257. MOV R0,#BUFF
  258. SJMP PSQC7E
  259. PSQNEXT1: MOV A,@R0
  260. JNZ PSQNEXT2
  261. INC R0
  262. INC R0
  263. INC R0
  264. SJMP PSQC7E
  265. PSQNEXT2: MOV CSN,@R0
  266. INC R0
  267. MOV 02H,@R0
  268. INC R0
  269. MOV 03H,@R0
  270. INC R0
  271. POP PSW
  272. LCALL CSDPTR
  273. INC DPTR
  274. INC DPTR
  275. RET
  276. ;8.曲号闪显子程序
  277. ;---------QNFDSUP(08)-------
  278. QNFDSUP: PUSH ACC
  279. MOV GEN16T0,#00H
  280. MOV GEN16T1,#00H
  281. QNGON: LCALL CSNSDISN
  282. LCALL DISPLAY
  283. MOV GENCLK,#00H
  284. QNWAIT: MOV A,GENCLK
  285. CJNE A,#35,QNWAIT
  286. MOV DISNUM0,#20H
  287. MOV DISNUM1,#20H
  288. LCALL DISPLAY
  289. MOV GENCLK,#00H
  290. QNWAIT1: MOV A,GENCLK
  291. CJNE A,#15,QNWAIT1
  292. MOV A,GEN16T1
  293. CJNE A,#02,QNGON
  294. POP ACC
  295. RET
  296. ;9.曲号送显示寄存器
  297. ;---------CSNSDISN(09)------
  298. CSNSDISN: MOV A,CSN
  299. ANL A,#0FH
  300. LCALL CSBESTOJG
  301. JNB CSBESTOF,NADP
  302. ADD A,#10H
  303. NADP: MOV DISNUM0,A
  304. MOV A,CSN
  305. SWAP A
  306. ANL A,#0FH
  307. MOV DISNUM1,A
  308. RET
  309. ;10.当前曲是否被存储判断
  310. ;---------CSBESTOJG(10)-----
  311. CSBESTOJG:PUSH ACC
  312. PUSH PSW
  313. MOV A,BUFF0
  314. JZ CLRCSTOF
  315. MOV R0,#BUFF
  316. CSBCMPCSN:MOV A,@R0
  317. CJNE A,CSN,CSBGSCAN
  318. SETB CSBESTOF
  319. SJMP CSBRET
  320. CSBGSCAN: INC R0
  321. INC R0
  322. INC R0
  323. CJNE R0,#7EH,CSBNEXT
  324. CSBNEXT: JC CSBCMPCSN
  325. CLRCSTOF: CLR CSBESTOF
  326. MOV R0,#BUFF
  327. CSBCMP0: MOV A,@R0
  328. JZ CSBRET
  329. INC R0
  330. INC R0
  331. INC R0
  332. CJNE R0,#7EH,CSBNEXT1
  333. CSBNEXT1: JC CSBCMP0
  334. CSBRET: POP PSW
  335. POP ACC
  336. RET
  337. ;11.找当前曲首址
  338. ;---------CSDPTR(11)--------
  339. CSDPTR: MOV DPTR,#T_SONGS
  340. CSDSCAN: LCALL RYFSUP
  341. CJNE R7,#0FFH,CSDNEXT
  342. MOV A,R6
  343. CJNE A,CSN,CSDNEXT
  344. SJMP CSDRET
  345. CSDNEXT: INC DPTR
  346. INC DPTR
  347. SJMP CSDSCAN
  348. CSDRET: RET
  349. ;12.重复段处理子程序
  350. ;---------REPCLSUP(12)------
  351. REPCLSUP: MOV A,R7
  352. ANL A,#0FH
  353. CJNE A,#02H,CMPA3
  354. MOV A,R7
  355. SWAP A
  356. ANL A,#0FH
  357. JNZ H4CMP1
  358. JNB REP0F,REPRET0
  359. CLR REP0F
  360. MOV DPL,REP0L
  361. MOV DPH,REP0H
  362. REPRET0: RET
  363. H4CMP1: CJNE A,#01H,H4CMP2
  364. JNB REP1F,REPRET
  365. CLR REP1F
  366. MOV DPL,REP1L
  367. MOV DPH,REP1H
  368. RET
  369. H4CMP2: CJNE A,#02H,H4CMP3
  370. JNB REP2F,REPRET
  371. CLR REP2F
  372. MOV DPL,REP2L
  373. MOV DPH,REP2H
  374. RET
  375. H4CMP3: CJNE A,#03H,REPRET
  376. JNB REP3F,REPRET
  377. CLR REP3F
  378. MOV DPL,REP3L
  379. MOV DPH,REP3H
  380. RET
  381. CMPA3: CJNE A,#03H,REPRET
  382. MOV A,R7
  383. SWAP A
  384. ANL A,#0FH
  385. JNZ H4VS1
  386. SETB REP0F
  387. MOV REP0L,DPL
  388. MOV REP0H,DPH
  389. SJMP SREPHAD
  390. H4VS1: CJNE A,#01H,H4VS2
  391. SETB REP1F
  392. MOV REP1L,DPL
  393. MOV REP1H,DPH
  394. SJMP SREPHAD
  395. H4VS2: CJNE A,#02H,H4VS3
  396. SETB REP2F
  397. MOV REP2L,DPL
  398. MOV REP2H,DPH
  399. SJMP SREPHAD
  400. H4VS3: CJNE A,#03H,REPRET
  401. SETB REP3F
  402. MOV REP3L,DPL
  403. MOV REP3H,DPH
  404. SREPHAD: MOV 09H,A
  405. LCALL CSDPTR
  406. REPGON: INC DPTR
  407. INC DPTR
  408. LCALL RYFSUP
  409. CJNE R6,#0FFH,REPGON
  410. MOV A,R7
  411. SWAP A
  412. ANL A,#0FH
  413. CJNE A,09H,REPGON
  414. REPRET: RET
  415. ;13.音符显示子程序
  416. ;---------YFDSUP(13)--------
  417. YFDSUP: MOV A,STATU
  418. JNZ YFDRET
  419. JB SECHSTOF,YFDRET
  420. JNB CUYFD,YFSLED
  421. XZFCLD: MOV DISNUM0,#20H
  422. MOV DISNUM1,#20H
  423. SJMP YFDSPLAY
  424. YFSLED: MOV A,R6
  425. JZ XZFCLD
  426. ANL A,#0FH
  427. PUSH DPL
  428. PUSH DPH
  429. MOV DPTR,#T_YFDCOD
  430. MOVC A,@A+DPTR
  431. MOV DISNUM0,A
  432. POP DPH
  433. POP DPL
  434. MOV A,R6
  435. SWAP A
  436. ANL A,#0FH
  437. MOV DISNUM1,A
  438. YFDSPLAY: LCALL DISPLAY
  439. YFDRET: RET
  440. T_YFDCOD: DB 20H ;--
  441. DB 01H ; 1
  442. DB 02H ; 2
  443. DB 03H ; 3
  444. DB 04H ; 4
  445. DB 05H ; 5
  446. DB 06H ; 6
  447. DB 07H ; 7
  448. DB 11H ;#1
  449. DB 12H ;#2
  450. DB 14H ;#4
  451. DB 15H ;#5
  452. DB 16H ;#6
  453. ;14.唱音符子程序
  454. ;---------PLAY(14)----------
  455. PLAY: MOV A,R6
  456. JZ PCOSPECL
  457. PUSH DPL
  458. PUSH DPH
  459. MOV DPTR,#T_SD
  460. ANL A,#0FH
  461. MOVC A,@A+DPTR
  462. XCH A,R6
  463. SWAP A
  464. ANL A,#0FH
  465. MOV B,#12
  466. MUL AB
  467. ADD A,R6
  468. ADD A,R2
  469. RL A
  470. MOV R6,A
  471. MOV DPTR,#T_RAN
  472. MOVC A,@A+DPTR
  473. MOV TH0,A
  474. MOV R5,A
  475. MOV A,R6
  476. INC A
  477. MOVC A,@A+DPTR
  478. MOV TL0,A
  479. MOV R4,A
  480. POP DPH
  481. POP DPL
  482. SETB TR0
  483. PCOSPECL: LCALL COSPECL
  484. PJPWAIT: MOV JPCLK,#00H
  485. PDELAY: LCALL KCXCL
  486. JB NEXTSF,PRET
  487. MOV A,JPCLK
  488. CJNE A,01H,PNEXT
  489. PNEXT: JC PDELAY
  490. DJNZ R7,PJPWAIT
  491. PRET: CLR TR0
  492. RET
  493. ;---------TABSD-------------
  494. T_SD: DB 01h ;useless
  495. DB 01H
  496. DB 03H
  497. DB 05H
  498. DB 06H
  499. DB 08H
  500. DB 0AH
  501. DB 0CH
  502. DB 02H
  503. DB 04H
  504. DB 07H
  505. DB 09H
  506. DB 0bH
  507. ;---------TABRAN------------
  508. T_RAN: DW 0F111H ;useless
  509. dw 0f111h ; area 0
  510. dw 0f1e8h
  511. dw 0f2b2h
  512. dw 0f373h
  513. dw 0f426h
  514. dw 0f4eeh
  515. dw 0f571h
  516. dw 0f609h
  517. dw 0f699h
  518. dw 0f71fh
  519. dw 0f79fh
  520. dw 0f817h
  521. dw 0f889h ; area 1
  522. dw 0f8f4h
  523. dw 0f95ah
  524. dw 0f9b9h
  525. dw 0fa13h
  526. dw 0fa68h
  527. dw 0fab9h
  528. dw 0fb04h
  529. dw 0fb4ch
  530. dw 0fb90h
  531. dw 0fbcfh
  532. dw 0fc0ch
  533. dw 0fc45h ;area 2
  534. dw 0fc7ah
  535. dw 0fcadh
  536. dw 0fcdch
  537. dw 0fd0ah
  538. dw 0fd34h
  539. dw 0fd5ch
  540. dw 0fd82h
  541. dw 0fda6h
  542. dw 0fdc8h
  543. dw 0fde8h
  544. dw 0fe06h
  545. dw 0fe22h ; area 3
  546. dw 0fe3dh
  547. dw 0fe56h
  548. dw 0fe6eh
  549. dw 0fe85h
  550. dw 0fe9ah
  551. dw 0feaeh
  552. dw 0fec1h
  553. dw 0fed3h
  554. dw 0fee3h
  555. dw 0fef4h
  556. dw 0ff02h
  557. dw 0ff11h ;area 4
  558. dw 0ff1fh
  559. dw 0ff2bh
  560. dw 0ff37h
  561. dw 0ff42h
  562. dw 0ff4dh
  563. dw 0ff57h
  564. dw 0ff60h
  565. dw 0ff6ah
  566. dw 0ff72h
  567. dw 0ff7ah
  568. dw 0ff81h
  569. dw 0ff89h ; 5
  570. ;15.共速处理
  571. ;---------COSPECL(15)-------
  572. COSPECL: MOV R1,03H
  573. MOV A,COSPEEDN
  574. JZ COSPRET
  575. PUSH COSPEEDN
  576. MOV A,R1
  577. COSPEGON: MOV B,#08H
  578. MUL AB
  579. CLR C
  580. SUBB A,R1
  581. JNC COSPNEXT
  582. DEC B
  583. COSPNEXT: MOV R6,#03H
  584. DIV8: CLR C
  585. XCH A,B
  586. RRC A
  587. XCH A,B
  588. RRC A
  589. DJNZ R6,DIV8
  590. MOV R1,A
  591. DJNZ COSPEEDN,COSPEGON
  592. POP COSPEEDN
  593. MOV A,R1
  594. JNZ COSPRET
  595. MOV R1,#01H
  596. COSPRET: RET
  597. ;16.键盘查询处理
  598. ;---------KCXCL(16)---------
  599. KCXCL: LCALL KSET
  600. LCALL KALT0
  601. LCALL KALT1
  602. JNB KSETF,KNEXT0
  603. LCALL KSETCL
  604. KSETSTC: MOV SETST0,#00H
  605. MOV SETST1,#00H
  606. SETB KBDISF
  607. SJMP KDIS
  608. KNEXT0: JNB KALT0F,KNEXT1
  609. LCALL KALT0CL
  610. SJMP KSETSTC
  611. KNEXT1: JNB KALT1F,KDIS
  612. LCALL KALT1CL
  613. SJMP KSETSTC
  614. KDIS: MOV A,STATU
  615. JNZ KSSNSD
  616. JNB SECHSTOF,KRET
  617. KSSNSD: JNB KBDISF,KRET
  618. CLR KBDISF
  619. LCALL DISPLAY
  620. KRET: RET
  621. ;17.KSET键是否按下查询
  622. ;---------KSET(17)----------
  623. KSET: SETB SET
  624. JB SET,CSETRET
  625. MOV GENCLK,#00H
  626. SETLOP: MOV A,GENCLK
  627. CJNE A,#02,SETLOP
  628. SETB SET
  629. JB SET,CSETRET
  630. CLR TR0
  631. SETWAIT: SETB SET
  632. JNB SET,SETWAIT
  633. MOV GENCLK,#00H
  634. SETLOP1: MOV A,GENCLK
  635. CJNE A,#02,SETLOP1
  636. SETB TR0
  637. SETB KSETF
  638. RET
  639. CSETRET: CLR KSETF
  640. RET
  641. ;18.KALT0键是否按下查询
  642. ;---------KALT0(18)---------
  643. KALT0: SETB ALT0
  644. JB ALT0,CALT0RET
  645. MOV GENCLK,#00H
  646. ALT0LOP: MOV A,GENCLK
  647. CJNE A,#02,ALT0LOP
  648. SETB ALT0
  649. JB ALT0,CALT0RET
  650. CLR TR0
  651. ALT0WAIT: SETB ALT0
  652. JNB ALT0,ALT0WAIT
  653. MOV GENCLK,#00H
  654. ALT0LOP1: MOV A,GENCLK
  655. CJNE A,#02,ALT0LOP1
  656. SETB TR0
  657. SETB KALT0F
  658. RET
  659. CALT0RET: CLR KALT0F
  660. RET
  661. ;19.KALT1键是否按下查询
  662. ;---------KALT1(19)---------
  663. KALT1: SETB ALT1
  664. JB ALT1,CALT1RET
  665. MOV GENCLK,#00H
  666. ALT1LOP: MOV A,GENCLK
  667. CJNE A,#02,ALT1LOP
  668. SETB ALT1
  669. JB ALT1,CALT1RET
  670. CLR TR0
  671. ALT1WAIT: SETB ALT1
  672. JNB ALT1,ALT1WAIT
  673. MOV GENCLK,#00H
  674. ALT1LOP1: MOV A,GENCLK
  675. CJNE A,#02,ALT1LOP1
  676. SETB TR0
  677. SETB KALT1F
  678. RET
  679. CALT1RET: CLR KALT1F
  680. RET
  681. ;20.SET键处理
  682. ;---------KSETCL(20)--------
  683. KSETCL: INC STATU
  684. MOV A,STATU
  685. CJNE A,#07H,STATUDIS
  686. MOV STATU,#00H
  687. STATUDIS: MOV DISNUM0,#23H
  688. MOV DISNUM1,STATU
  689. RET
  690. ;21.KALT0键处理
  691. ;---------KALT0CL(21)-------
  692. KALT0CL: MOV A,STATU
  693. JNZ CASEB1
  694. KA0S0GO: INC DPTR
  695. INC DPTR
  696. LCALL RYFSUP
  697. MOV A,R7
  698. JNZ EQUFF
  699. MOV DPTR,#T_SONGS
  700. SJMP KA0NEXT
  701. EQUFF: INC A
  702. JNZ KA0S0GO
  703. KA0NEXT: LCALL RYFSUP
  704. MOV CSN,R6
  705. LCALL CSNSDISN
  706. MOV A,DPL
  707. CLR C
  708. SUBB A,#02H
  709. JNC KA0NEXT1
  710. DEC DPH
  711. KA0NEXT1: MOV DPL,A
  712. CLR REP0F
  713. CLR REP1F
  714. CLR REP2F
  715. CLR REP3F
  716. SETB NEXTSF
  717. SETB SECHSTOF
  718. RET
  719. CASEB1: CJNE A,#01H,CASEB2
  720. INC LDYDSR
  721. MOV A,LDYDSR
  722. CJNE A,#04H,LDYDSL4
  723. MOV LDYDSR,#00H
  724. LDYDSL4: MOV DISNUM0,LDYDSR
  725. MOV DISNUM1,#26H
  726. RET

  727. HCOSPEEDN EQU 12H
  728. CASEB2: CJNE A,#02H,CASEB3
  729. MOV A,COSPEEDN
  730. CJNE A,#HCOSPEEDN,KA0NEXT4
  731. KA0NEXT4: JNC KA0NEXT5
  732. INC COSPEEDN
  733. KA0NEXT5: MOV SPENR,COSPEEDN
  734. LCALL SPENSDISN
  735. RET
  736. CASEB3: CJNE A,#03H,CASEB4
  737. CLR SPEEDF
  738. LCALL SPEEDCL
  739. RET
  740. CASEB4: CJNE A,#04H,CASEB5
  741. CLR TONEF
  742. LCALL TONECL
  743. RET
  744. CASEB5: CJNE A,#05H,CASEB6
  745. CPL LOCF
  746. JNB LOCF,KA0NEXT2
  747. MOV DISNUM0,#24H
  748. SJMP KA0NEXT3
  749. KA0NEXT2: MOV DISNUM0,#25H
  750. KA0NEXT3: MOV DISNUM1,#26H
  751. RET
  752. CASEB6: CJNE A,#06H,KA0RET
  753. CPL CUYFD
  754. JNB CUYFD,KA0NEXT6
  755. MOV DISNUM0,#24H
  756. SJMP KA0NEXT7
  757. KA0NEXT6: MOV DISNUM0,#25H
  758. KA0NEXT7: MOV DISNUM1,#28H
  759. KA0RET: RET
  760. ;22.速度数送显示寄存器
  761. ;---------SPENSDISN(22)----
  762. SPENSDISN:MOV A,SPENR
  763. ANL A,#0FH
  764. MOV DISNUM0,A
  765. MOV A,SPENR
  766. SWAP A
  767. ANL A,#0FH
  768. MOV DISNUM1,A
  769. RET
  770. ;23.速度处理
  771. ;---------SPEEDCL(23)------
  772. HSPEED EQU 02H;
  773. LSPEED EQU 50H;
  774. SPEEDCL: JB SPEEDF,DNSPEED
  775. CJNE R3,#HSPEED,SCLNEXT
  776. SCLNEXT: JC SCLNEXT1
  777. DEC R3
  778. SJMP SCLNEXT1
  779. DNSPEED:
  780. CJNE R3,#LSPEED,SCLNEXT2
  781. SCLNEXT2: JNC SCLNEXT1
  782. INC R3
  783. SCLNEXT1: LCALL CSBESTOJG
  784. JNB CSBESTOF,SCLNEXT3
  785. INC R0
  786. INC R0
  787. MOV @R0,03H
  788. SCLNEXT3: LCALL COSPECL
  789. MOV SPENR,R1
  790. LCALL SPENSDISN
  791. RET
  792. ;24.音调处理
  793. ;---------TONECL(24)---------
  794. ;LTONE EQU 00 ;C
  795. HTONE EQU 11 ;B
  796. TONECL: JB TONEF,DNTONE
  797. CJNE R2,#HTONE,TCLNEXT0
  798. TCLNEXT0: JNC TCLNEXT
  799. INC R2
  800. SJMP TCLNEXT
  801. DNTONE: MOV A,R2
  802. JZ TCLNEXT
  803. DEC R2
  804. TCLNEXT: LCALL CSBESTOJG
  805. JNB CSBESTOF,TCLNEXT1
  806. INC R0
  807. MOV @R0,02H
  808. TCLNEXT1: PUSH DPL
  809. PUSH DPH
  810. MOV DPTR,#T_TONDISC
  811. MOV A,R2
  812. RL A
  813. MOVC A,@A+DPTR
  814. MOV DISNUM1,A
  815. MOV A,R2
  816. RL A
  817. INC A
  818. MOVC A,@A+DPTR
  819. MOV DISNUM0,A
  820. POP DPH
  821. POP DPL
  822. RET
  823. T_TONDISC:DW 200CH ; C
  824. DW 210CH ;#C
  825. DW 200DH ; D
  826. DW 210DH ;#D
  827. DW 200EH ; E
  828. DW 200FH ; F
  829. DW 210FH ;#F
  830. DW 2022H ; G
  831. DW 2122H ;#G
  832. DW 200AH ; A
  833. DW 210AH ;#A
  834. DW 200BH ; B
  835. ;25.KALT1键处理
  836. ;---------KALT1CL(25)--------
  837. KALT1CL: MOV A,STATU
  838. JNZ CASE1
  839. LCALL CSBESTOJG
  840. JNB CSBESTOF,KA1NEXT
  841. MOV @R0,#00H
  842. DEC BUFF0
  843. SJMP KA1NEXT2
  844. KA1NEXT: CJNE R0,#7EH,KA1NEXT1
  845. KA1NEXT1: JNC KA1NEXT2
  846. MOV @R0,CSN
  847. INC R0
  848. MOV @R0,02H
  849. INC R0
  850. MOV @R0,03H
  851. INC BUFF0
  852. KA1NEXT2: LCALL CSNSDISN
  853. SETB SECHSTOF
  854. RET
  855. CASE1: CJNE A,#01H,CASE2
  856. INC RDYDSR
  857. MOV A,RDYDSR
  858. CJNE A,#04H,RDYDSL4
  859. MOV RDYDSR,#00H
  860. RDYDSL4: MOV DISNUM0,RDYDSR
  861. MOV DISNUM1,#27H
  862. RET
  863. CASE2: CJNE A,#02H,CASE3
  864. MOV A,COSPEEDN
  865. JZ KA1NEXT5
  866. DEC COSPEEDN
  867. KA1NEXT5: MOV SPENR,COSPEEDN
  868. LCALL SPENSDISN
  869. RET
  870. CASE3: CJNE A,#03H,CASE4
  871. SETB SPEEDF
  872. LCALL SPEEDCL
  873. RET
  874. CASE4: CJNE A,#04H,CASE5
  875. SETB TONEF
  876. LCALL TONECL
  877. RET
  878. CASE5: CJNE A,#05H,CASE6
  879. CPL ROCF
  880. JNB ROCF,KA1NEXT3
  881. MOV DISNUM0,#24H
  882. SJMP KA1NEXT4
  883. KA1NEXT3: MOV DISNUM0,#25H
  884. KA1NEXT4: MOV DISNUM1,#27H
  885. RET
  886. CASE6: CJNE A,#06H,KA1RET
  887. MOV DISNUM0,#23H
  888. MOV DISNUM1,#06H
  889. KA1RET: RET
  890. ;========= 乐曲表============
  891. ;---------SONGS--------------
  892. T_SONGS: 乐曲表表首
  893. dw 01ffh,;song1:xiao la ba...
  894. dw 0b05h,
  895. dw 2504h,
  896. dw 2604h,
  897. dw 2506h,
  898. dw 0002h,
  899. dw 2504h,
  900. dw 2604h,
  901. dw 2506h,
  902. dw 0002h,
  903. dw 2504h,
  904. dw 2604h,
  905. dw 2504h,
  906. dw 2304h,
  907. dw 2204h,
  908. dw 2104h,
  909. dw 2206h,

  910. DW 16FFH;SONG16:Liang Zhi Lao Hu
  911. DW 0715H
  912. DW 0FF21H ;REP21
  913. DW 0FF01H ;REP01
  914. DW 2102H
  915. DW 2202H
  916. DW 2302H
  917. DW 2102H
  918. DW 0FF02H ;REP02
  919. DW 0FF03H ;REP03
  920. DW 2302H
  921. DW 2402H
  922. DW 2504H
  923. DW 2302H
  924. DW 2402H
  925. DW 2504H
  926. DW 0FF11H ;REP11
  927. DW 2501H
  928. DW 2601H
  929. DW 2501H
  930. DW 2401H
  931. DW 2302H
  932. DW 2102H
  933. DW 0FF12H ;REP12
  934. DW 0FF13H ;REP13
  935. DW 2202H
  936. DW 1502H
  937. DW 2104H
  938. DW 2202H
  939. DW 1502H
  940. DW 2104H
  941. DW 0FF22H ;REP22
  942. DW 0FF23H ;REP23

  943. DW 0000H ;乐曲表表尾
  944. END
  945. ;=========END================
复制代码

返回列表

最新关注 关闭


关于论坛注册,最新修改,请网友们注意

由于最近大量垃圾信息出现在我们的论坛,为了营造一个良好的氛围,目前论坛只开发邀请注册,你可以点击以下链接自动邀请注册(如果有人使用了点击下一个试一试) ...


查看
珩源工控论坛热诚欢迎您联系我们进行合作!

Powered by Discuz! 7.2© 2001-2009 Comsenz Inc.

珩源工控论坛 ( 桂ICP备19004328号) |论坛统计|WAP| 客服中心-www.hymcu.com
  

GMT+8, 2024-11-24 18:49, Processed in 1.079138 second(s), 5 queries, Gzip enabled.