单片机怎么实现演奏两首歌(生日快乐+两只老虎) 汇编语言
答案:2 悬赏:70 手机版
解决时间 2021-03-04 03:52
- 提问者网友:温柔港
- 2021-03-03 04:45
单片机怎么实现演奏两首歌(生日快乐+两只老虎) 汇编语言
最佳答案
- 五星知识达人网友:十年萤火照君眠
- 2021-03-03 05:29
;音乐生日快乐的播放
numtim equ 20h
EQUei equ 21h
EQUwei equ 22h
EQUnled equ 23h
EQU 000hORGp startJMPg 00bh
jORGtim0
oJMP100h
ORGart:; JB P3.7,$ ;检测播放按键是否按下
mov tmod,#00000001b
MOV mov ie,#10000010b
MOV mov numtim,#01h
startMOVov 30h,#00h
nextMOVv a,30h
mov MOVr,#table
MOVovc a,@a+dptr
mov r2,a
jz eMOV
anl aJZ0fh
mov r5,a
mov aMOV
swap MOV anl a,#0fh
jnz sing
clr tJNZ
jmp d1
sing: dec aJMP mov 22h,DEC rl aMOV mov dptr,#table1
MOVmovc a,@a+dptr
mov th0,a
mov MOV,a
mov MOV2h
rl aMOV inc a
movc a,@INCptr
mov tl0,a
mov MOV,a
setbMOV0
d1:lcall delay
inc 30h
jmp neINC
end0:clr JMP
jmp start0
tim0:puJMPacc
pushPUSH
mov PUSH2PSW
MOV th0,21h
MOV p1.6 ;由该口输出音频数据
pop psw
pop acc
POPrPSW
dPOPy: mov r7,#02h
d2: mov r4,#1MOV
d3: mov r3,#MOV
djnz r3,MOV djnz r4,d3
djnz r7,d2
djnz r5,delay
ret
table1: RET ;音乐码表
dw 64260,64400,64524,64580
DW dw 64684,64777,64820,64898
DW dw 64968,65030,65058,65110
DW dw 65157,65178,65217
table:dDW82h,01h,81h,94h,84h
DB 0b4h,0a4h,04h
db 82hDB1h,81h,94h,84h
DB 0c4h,0b4h,04h
db 8DB,01h,81h,0f4h,0d4h
DBdb 0b4h,0a4h,94h
db 0e2DB01h,0e1h,0d4h,0b4h
DB db 0c4h,0b4h,04h
db 8DB,01h,81h,94h,84h
DB 0b4h,0a4h,04h
db 82hDB1h,81h,94h,84h
DB 0c4h,0b4h,04h
db 8DB,01h,81h,0f4h,0d4h
DBdb 0b4h,0a4h,94h
db 0e2DB01h,0e1h,0d4h,0b4h
DB db 0c4h,0b4h,04h
db 00DB
TABLE2:DB 0C0H,0F9H,DB4H,0B0H,99H,92H,8DB,0F8H,80H,90H
end
END
我只有生日快乐的程序,希望对你有帮助,从我这个程序你了解了原理,你就可以随意搞了,玩熟悉了就简单了!
numtim equ 20h
EQUei equ 21h
EQUwei equ 22h
EQUnled equ 23h
EQU 000hORGp startJMPg 00bh
jORGtim0
oJMP100h
ORGart:; JB P3.7,$ ;检测播放按键是否按下
mov tmod,#00000001b
MOV mov ie,#10000010b
MOV mov numtim,#01h
startMOVov 30h,#00h
nextMOVv a,30h
mov MOVr,#table
MOVovc a,@a+dptr
mov r2,a
jz eMOV
anl aJZ0fh
mov r5,a
mov aMOV
swap MOV anl a,#0fh
jnz sing
clr tJNZ
jmp d1
sing: dec aJMP mov 22h,DEC rl aMOV mov dptr,#table1
MOVmovc a,@a+dptr
mov th0,a
mov MOV,a
mov MOV2h
rl aMOV inc a
movc a,@INCptr
mov tl0,a
mov MOV,a
setbMOV0
d1:lcall delay
inc 30h
jmp neINC
end0:clr JMP
jmp start0
tim0:puJMPacc
pushPUSH
mov PUSH2PSW
MOV th0,21h
MOV p1.6 ;由该口输出音频数据
pop psw
pop acc
POPrPSW
dPOPy: mov r7,#02h
d2: mov r4,#1MOV
d3: mov r3,#MOV
djnz r3,MOV djnz r4,d3
djnz r7,d2
djnz r5,delay
ret
table1: RET ;音乐码表
dw 64260,64400,64524,64580
DW dw 64684,64777,64820,64898
DW dw 64968,65030,65058,65110
DW dw 65157,65178,65217
table:dDW82h,01h,81h,94h,84h
DB 0b4h,0a4h,04h
db 82hDB1h,81h,94h,84h
DB 0c4h,0b4h,04h
db 8DB,01h,81h,0f4h,0d4h
DBdb 0b4h,0a4h,94h
db 0e2DB01h,0e1h,0d4h,0b4h
DB db 0c4h,0b4h,04h
db 8DB,01h,81h,94h,84h
DB 0b4h,0a4h,04h
db 82hDB1h,81h,94h,84h
DB 0c4h,0b4h,04h
db 8DB,01h,81h,0f4h,0d4h
DBdb 0b4h,0a4h,94h
db 0e2DB01h,0e1h,0d4h,0b4h
DB db 0c4h,0b4h,04h
db 00DB
TABLE2:DB 0C0H,0F9H,DB4H,0B0H,99H,92H,8DB,0F8H,80H,90H
end
END
我只有生日快乐的程序,希望对你有帮助,从我这个程序你了解了原理,你就可以随意搞了,玩熟悉了就简单了!
全部回答
- 1楼网友:行雁书
- 2021-03-03 06:43
org 0000h
ajmp main
org 000bh
ajmp t0int
org 0050h
main: mov tmod,#01h
mov ie,#82h
again: mov dptr,#tab;表首地址
loop: clr a
movc a,@a+dptr
mov r2,a ;时间高位
inc dptr
clr a
movc a,@a+dptr
mov r3,a;时间低位 2
orl a,r2
jz stop
mov a,r2
anl a,r3
cjne a,#0ffh,next
ajmp again
next: mov th0,r2
mov tl0,r3
setb tr0
next1: clr a
inc dptr
movc a,@a+dptr
mov p1,a;字形码显示 3
clr a
inc dptr
movc a,@a+dptr; 延时常数 4
del: mov r5, 2
del0: mov r6 ,#250
del1: mov r7, #248
nop
del2: djnz r7, del2
djnz r6,del1
djnz r5,del0
clr tr0
inc dptr;下一个音节
ljmp loop
stop: ajmp next1
t0int: push a
push psw
push dph
push dpl
cpl p3.0;音频取反
mov th0,r2
mov tl0,r3
setb tr0
pop dpl
pop dph
pop psw
pop a
reti
tab: db
在tab后把简谱打上
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯