邊顯示滾動(dòng)漢字邊播放音樂的匯編程序
//=======第四首==================================
MAIN5:MOV P0,#0FFH
MOV P1,#0FH
MOV P2,#00H
MOV 30H,#00H //奏第四首循環(huán)
MOV A,R7
CJNE A,#04H,LMAIN5
LOO2P:SETB TR0
MOV A,30H
MOV DPTR,#TAB16
MOVC A,@A+DPTR ;取定時(shí)器高八位數(shù)據(jù)
JZ RERT3
LOO21: MOV R0,A
MOV A,30H
MOV DPTR,#TAB17
MOVC A,@A+DPTR ;取定時(shí)器低八位數(shù)據(jù)
MOV R1,A
MOV TH0,R0
MOV TL0,R1
ANL A,R0
CJNE A,#0FFH,NCA5 ;遇0FFH歌曲結(jié)束
LJMP ENDD5
NCA5: MOV A,30H
MOV DPTR,#TAB18
MOVC A,@A+DPTR ;取節(jié)拍時(shí)值
MOV R2,A
DELA41:ACALL DELAY100
DEL41:DJNZ R2,DELA41
INC 30H
LJMP LOO2P
RERT3:CLR TR0 ;休止
SETB YY
LJMP LOO21
ENDD5:CLR TR0
ACALL DELAY1000
LJMP MAIN5 ;奏完返回
LMAIN5:LJMP MAIN6
//=======第五首==================================
MAIN6:MOV P0,#0FFH
MOV P1,#0FH
MOV P2,#00H
MOV 30H,#00H //奏第五首循環(huán)
MOV A,R7
CJNE A,#05H,LMAIN6
LOO4P:SETB TR0
MOV A,30H
MOV DPTR,#TAB19
MOVC A,@A+DPTR ;取定時(shí)器高八位數(shù)據(jù)
JZ RERT4
LOO31: MOV R0,A
MOV A,30H
MOV DPTR,#TAB20
MOVC A,@A+DPTR ;取定時(shí)器低八位數(shù)據(jù)
MOV R1,A
MOV TH0,R0
MOV TL0,R1
ANL A,R0
CJNE A,#0FFH,NCA6 ;遇0FFH歌曲結(jié)束
LJMP ENDD6
NCA6: MOV A,30H
MOV DPTR,#TAB21
MOVC A,@A+DPTR ;取節(jié)拍時(shí)值
MOV R2,A
DELA51:ACALL DELAY100
DEL51:DJNZ R2,DELA51
INC 30H
LJMP LOO4P
RERT4:CLR TR0 ;休止
SETB YY
LJMP LOO31
ENDD6:CLR TR0
ACALL DELAY1000
LJMP MAIN6 ;奏完返回
LMAIN6:CLR TR1
LJMP MAIN3
//======流動(dòng)漢字=================================
MAIN3:
MOV A,R7
CJNE A,#06H,LMA3
SJMP XIAN
LMA3:LJMP MAKK
XIAN:CLR TR0
MOV A,30H
MOV DPTR,#TAB7
MOVC A,@A+DPTR
MOV P0,A
MOV A,30H
MOV DPTR,#TAB8
MOVC A,@A+DPTR
MOV P1,A
MOV A,30H
MOV DPTR,#TAB9
MOVC A,@A+DPTR
MOV P2,A
//--------------------------------------
MA3D://掃描按鍵延時(shí)
MOV 53H,#5
MA3D2:
JB P3.2,LMA03 ;按鍵
LCALL WDELAY
INC R7
CJNE R7,#04H,MA32
MOV R7,#00H
MA32:LJMP MAKK
LMA03:JB P3.3,MA3D1
LCALL WDELAY
LCALL SIMAIN1 ;跳到顯示死循環(huán)子程序
MA3D1:DJNZ 53H,MA3D2
//---------------------------------------
MOV P0,#0FFH
MOV P1,#0FH
MOV P2,#00H
DJNZ 31H,XIAN
MOV 31H,#24
INC 30H
MOV A,30H
CJNE A,#13,XIAN1
DJNZ 40H,XIA1
MOV 40H,#100
LJMP XIAN1
XIA1:MOV 30H,#0
LJMP MAIN3
XIAN1:
CJNE A,#25, XIAN2
MOV 36H,#13
DJNZ 40H,XIA2
MOV 40H,#100
LJMP XIAN2
XIA2:MOV 30H,#13
LJMP MAIN3
XIAN2:
CJNE A,#37,XIAN3
MOV 36H,#25
DJNZ 40H,XIA3
MOV 40H,#100
LJMP XIAN3
XIA3:MOV 30H,#25
LJMP MAIN3
XIAN3:
CJNE A,#49,XIAN4
MOV 36H,#37
DJNZ 40H,XIA4
MOV 40H,#100
LJMP XIAN4
XIA4:MOV 30H,#37
LJMP MAIN3
XIAN4:
CJNE A,#61,XIAN5
MOV 36H,#49
DJNZ 40H,XIA5
MOV 40H,#100
LJMP XIAN5
XIA5:MOV 30H,#49
LJMP MAIN3
XIAN5:
CJNE A,#73,XIAN6
MOV 36H,#61
DJNZ 40H,XIA6
MOV 40H,#100
LJMP XIAN6
XIA6:MOV 30H,#61
LJMP MAIN3
XIAN6:
CJNE A,#85,XIAN7
MOV 36H,#73
DJNZ 40H,XIA7
MOV 40H,#100
LJMP XIAN7
XIA7:MOV 30H,#73
LJMP MAIN3
XIAN7:
CJNE A,#97,XIAN8
MOV 36H,#85
DJNZ 40H,XIA8
MOV 40H,#100
LJMP XIAN8
XIA8:MOV 30H,#85
LJMP MAIN3
XIAN8:
CJNE A,#109,XIAN9
MOV 36H,#97
DJNZ 40H,XIA9
MOV 40H,#100
LJMP XIAN9
XIA9:MOV 30H,#97
LJMP MAIN3
XIAN9:
CJNE A,#121,XIAN10
MOV 36H,#109
DJNZ 40H,XIA10
MOV 40H,#100
LJMP XIAN10
XIA10:MOV 30H,#109
LJMP MAIN3
XIAN10:
CJNE A,#133,XIAN11
MOV 36H,#121
DJNZ 40H,XIA11
MOV 40H,#100
LJMP XIAN11
XIA11:MOV 30H,#121
LJMP MAIN3
XIAN11:
CJNE A,#145,END30
/* MOV 36H,#133
DJNZ 40H,XIA12
MOV 40H,#100
LJMP XIAN12
XIA12:MOV 30H,#133
LJMP MAIN3
XIAN12:
CJNE A,#157,XIAN13
MOV 36H,#145
DJNZ 40H,XIA13
MOV 40H,#100
LJMP XIAN13
XIA13:MOV 30H,#145
LJMP MAIN3
XIAN13:
CJNE A,#169,XIAN14
MOV 36H,#157
DJNZ 40H,XIA14
MOV 40H,#100
LJMP XIAN14
XIA14:MOV 30H,#157
LJMP MAIN3
XIAN14:
CJNE A,#181,END30 */
MOV 36H,#0
MOV 30H,#0
END30:LJMP MAIN3
//=======顯示死循環(huán)子程序========================
SIMAIN1:MOV 30H,36H
MOV 37H,#12
SIMAIN2:MOV A,30H
MOV DPTR,#TAB7
MOVC A,@A+DPTR
MOV P0,A
MOV A,30H
MOV DPTR,#TAB8
MOVC A,@A+DPTR
MOV P1,A
MOV A,30H
MOV DPTR,#TAB9
MOVC A,@A+DPTR
MOV P2,A
//-----------------
YANSI:MOV 38H,#200
YANS1:JB P3.3,YANS2
LCALL WDELAY
LJMP SIMRET
YANS2:DJNZ 38H,YANS1
//-----------------
INC 30H
MOV P0,#0FFH
MOV P1,#0FH
MOV P2,#00H
DJNZ 37H,SIMAIN2
LJMP SIMAIN1
SIMRET:RET
//=====定時(shí)器中斷服務(wù)子程序======================
T00:MOV TH0,R0
MOV TL0,R1
CPL YY
RETI
//==========定時(shí)器T1溢出中斷服務(wù)子程序============
T11:MOV TH1,#15H
MOV TL1,#0A0H
CJNE R3,#1,NET10
MOV P2,#06H
MOV P0,#55H
NET10:CJNE R3,#10,NET11
MOV P2,#09H
MOV P0,#0AAH
NET11:CJNE R3,#20,NET12
MOV R3,#0
NET12:
INC R3
// INC 30H //下一顯示值
RETI
//======延時(shí)子程序================================
//-------含按鍵------------
DELAY1000:MOV R4,#10
DELAY100: MOV R5,#6
DELAY1: MOV R6,#10
DELAY2: JB P3.2,DJNN
ACALL WDELAY
INC R7
CJNE R7,#08h,LJ
MOV R7,#00H
LJ: LJMP MAIN0
DJNN: JB P3.3,DJNN1
ACALL WDELAY
LCALL YINYEXI
DJNN1: DJNZ R6,DELAY2
DJNZ R5,DELAY1
DJNZ R4,DELAY100
RET
//-------500MS--------------
WDELAY:MOV 50H,#5
WDELA1:MOV 51H,#250
WDELA2:MOV 52H,#100
WDELA3:NOP
NOP
DJNZ 52H,WDELA3
DJNZ 51H,WDELA2
DJNZ 50H,WDELA1
RET
//======音樂暫停等待==============================
YINYEXI:
CLR TR0
MOV P0,#0F6H
MOV P1,#0FH
MOV P2,#3FH
JB P3.3,YINYEXI
ACALL WDELAY
MOV P0,#0FFH
MOV P2,#00H
SETB TR0
RET
//===========================================================
//月亮代表我的心>> 數(shù)據(jù)表
TAB1: //定時(shí)器高八位數(shù)據(jù)
DB 00H,0FBH,0FCH,0FDH,0FDH,0FCH,0FCH,0FDH,0FDH,00H
DB 0FDH,0FDH,0FEH,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09H,0ACH,00H,05H
DB 44H,09H,82H,44H,0CH,09H,82H,82H,0C8H,06H
DB 22H,0C8H,0C8H,82H,09H,0ACH,44H,44H,44H,09H
DB 0ACH,44H,44H,44H,0ACH,09H,0ACH,90H,0CH,44H
DB 0ACH,44H,0FFH
TAB3: //節(jié)拍時(shí)值表
db 4,4,12,4,12,4,12,4,8,4
db 4,4,8,12,4,4,28,4,4,12
db 4,8,4,4,12,4,8,4,4,8
db 4,8,4,4,24,4,4,12,4,12
db 4,12,4,8,4,4,4,8,12,4
db 4,28,4,4,12,4,8,4,4,12
db 4,8,4,4,8,4,8,4,4,24
db 4,4,12,4,8,8,24,4,4,12
db 4,12,8,24,8,12,4,8,8,24
db 4,4,12,4,8,4,4,24,4,4
db 12,4,12,4,12,4,12,4,12,4
db 12,4,4,20,4,4,12,4,8,4
db 4,12,4,8,4,4,12,4,8,4
db 4,24
評(píng)論