主题:跪求把汇编转换成C语言!!!!!谢谢啦!!!
一,happy birthday 生日快乐歌用21个音阶设计的程序
Void happy birthday()要用C51格式写程序!
{
setb tr0(tr0=1;) ;启动定时器0
start0:
setb p3.3;
30h=0x00;
next:
mov a,30h
mov dptr,#table
inc dptr
movc a,@a+dptr
mov r5,a ;将节拍码存入r5
cjne a,#0ffh,next1
jmp ennd
next1:
clr c
mov a,dpl
subb a,#1
mov dpl,a
mov a,dph
subb a,#0
mov dph,a
mov a,30h
movc a,@a+dptr
jnz sing
clr tr0 ;休止符?是,则不发音
jmp d1 ;跳到d1
sing:
dec a ;取到的音符码减1
mov 22h,a ;存入(22h)
rl a ; 乘2
mov dptr,#table1 ;至table1取相对应的高字节
movc a,@a+dptr
mov th0,a ;取到的高字节存入TH0
mov 21h,a ;取到的高字节存入(21h)
mov a,22h ;乘2
rl a ;加1
inc a ;至table1取相对应的低位
movc a,@a+dptr
mov tl0,a ;取到低字节存入tl0
mov 20h,a ;取到低字节存入(20h)
setb tr0 ;启动timer0
d1:
call delay ;声音延时 基本单位时间 1/4拍187毫秒
inc 30h ;取简码简指针加1
inc 30h ;取简码简指针加1
jmp next ;取下一个码
ennd:
clr tr0 ;停止timer0
ret
table:
db 12,2,0,1,12,2,13,4,12,4,15,4,14,4,0,4
db 12,2,0,1,12,1,13,4,12,4,16,4,15,4,0,4
db 12,2,0,1,12,1,19,4,17,4,15,4,14,4,13,4
db 18,2,0,1,18,1,17,4,15,4,16,4,15,4,0,4
db 12,2,0,1,12,1,13,4,12,4,15,4,14,4,0,4
db 12,2,0,1,12,1,13,4,12,4,16,4,15,4,0,4
db 12,2,0,1,12,1,19,4,17,4,15,4,14,4,13,4
db 18,2,0,1,15,1,17,4,15,4,16,4,15,4,0,4,0ffh,0ffh
}
Void happy birthday()要用C51格式写程序!
{
setb tr0(tr0=1;) ;启动定时器0
start0:
setb p3.3;
30h=0x00;
next:
mov a,30h
mov dptr,#table
inc dptr
movc a,@a+dptr
mov r5,a ;将节拍码存入r5
cjne a,#0ffh,next1
jmp ennd
next1:
clr c
mov a,dpl
subb a,#1
mov dpl,a
mov a,dph
subb a,#0
mov dph,a
mov a,30h
movc a,@a+dptr
jnz sing
clr tr0 ;休止符?是,则不发音
jmp d1 ;跳到d1
sing:
dec a ;取到的音符码减1
mov 22h,a ;存入(22h)
rl a ; 乘2
mov dptr,#table1 ;至table1取相对应的高字节
movc a,@a+dptr
mov th0,a ;取到的高字节存入TH0
mov 21h,a ;取到的高字节存入(21h)
mov a,22h ;乘2
rl a ;加1
inc a ;至table1取相对应的低位
movc a,@a+dptr
mov tl0,a ;取到低字节存入tl0
mov 20h,a ;取到低字节存入(20h)
setb tr0 ;启动timer0
d1:
call delay ;声音延时 基本单位时间 1/4拍187毫秒
inc 30h ;取简码简指针加1
inc 30h ;取简码简指针加1
jmp next ;取下一个码
ennd:
clr tr0 ;停止timer0
ret
table:
db 12,2,0,1,12,2,13,4,12,4,15,4,14,4,0,4
db 12,2,0,1,12,1,13,4,12,4,16,4,15,4,0,4
db 12,2,0,1,12,1,19,4,17,4,15,4,14,4,13,4
db 18,2,0,1,18,1,17,4,15,4,16,4,15,4,0,4
db 12,2,0,1,12,1,13,4,12,4,15,4,14,4,0,4
db 12,2,0,1,12,1,13,4,12,4,16,4,15,4,0,4
db 12,2,0,1,12,1,19,4,17,4,15,4,14,4,13,4
db 18,2,0,1,15,1,17,4,15,4,16,4,15,4,0,4,0ffh,0ffh
}