| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 415 人关注过本帖
标题:求助汇编转变成C语言!!!!!!!!
只看楼主 加入收藏
zj57421017
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-5-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求助汇编转变成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 interrupt intt0:            ;定时器中断服务程序
{   
push psw                     :将psw的值存于堆栈区                       
    push acc                       
    mov tl0,20h                  ;将psw的值暂存于堆栈区 重设计数值
    mov th0,21h               
    cpl p3.3                     ;将输出口p3.3取反
    pop acc                      ;至堆栈区取回psw的值
    pop psw                      ;至堆栈区
   
}
三、延迟程序
void delay()用C51格式写!
{
    mov r7,#02
delay0:
    mov r4,#187
delay1:
    mov r3,#248
    djnz r3,$
    djnz r4,delay1
    djnz r7,delay0               ;延时因子               
    djnz r5,delay                ;决定节拍
    }
end
四、液晶显示程序
void DealyS(unsigned int dly)
{
    unsigned int i;
    for(;dly>0;dly--)
    {
        for(i=0;i<1000;i++);
    }


}
五、键盘扫描处理程序(二个键)

void keyCheck(void)
{
    if((Key1Flag==0)&&(KEY1==1))Key1Flag=1
        else if((Key1flag==1)&&(KEY1==0))
    {
        DelayS(10);
        if(KEY1==0)
        {
            Key1Flag=0;
            counter++;
            menu++;

        }
    }
    if((Key2Flag==0)&&(KEY2==1))Key2Flag=1
        else if((Key2flag==1)&&(KEY2==0))
    {
        DelayS(10);
        if(KEY2==0)
        {
            Key1Flag=0;
            counter--;
            else counter=9;
        }
    }
if((Key3Flag==0)&&(KEY3==1))Key3Flag=1
{……}
……
}
六、键盘处理程序
void keyProcess(void)
{
    switch(menu)

    case0:
    {
        LCM_DisStr(1,1,"LCM_DisStr(1,1,"Select the following songs");
        LCM_DisStr(1,1,"LCM_DisStr(1,2,"HAPPY BIRTHDAY");
        LCM_DisStr(1,1,"LCM_DisStr(1,3,"My heart will go on");
        LCM_DisStr(1,1,"LCM_DisStr(1,4," TAKE ME TO YOUR HEART ");
    }
Case2:
    {
        LCM_DisStr(1,1,"LCM_DisStr(1,1," HAPPY BIRTHDAY ");
        LCM_DisStr(1,1,"LCM_DisStr(1,2, "My heart will go on ");
        LCM_DisStr(1,1,"LCM_DisStr(1,3, "TAKE ME TO YOUR HEART  ");
        LCM_DisStr(1,1,"LCM_DisStr(1,4,"NEVER ON SUNDAY ");
    }
Case3:
    {
        LCM_DisStr(1,1,"LCM_DisStr(1,1," My heart will go on ");
        LCM_DisStr(1,1,"LCM_DisStr(1,2, " TAKE ME TO YOUR HEART ");
        LCM_DisStr(1,1,"LCM_DisStr(1,3, " NEVER ON SUNDAY ");
        LCM_DisStr(1,1,"LCM_DisStr(1,4,"  SAY YOU SAY ME ");
    }
Case4:
    {
        LCM_DisStr(1,1,"LCM_DisStr(1,1," TAKE ME TO YOUR HEART ");
        LCM_DisStr(1,1,"LCM_DisStr(1,2, " NEVER ON SUNDAY ");
        LCM_DisStr(1,1,"LCM_DisStr(1,3, " SAY YOU SAY ME ");
        LCM_DisStr(1,1,"LCM_DisStr(1,4," THE TIME OF MY LIFE ");
    }
Case5:播放乐曲
{
Happy birthday();
}
Case6:
{
……
}

}

主程序
#include "CONFIg.h"
#include "CONFIg.h"
sbit KEY1=P1^1;
sbit KEY2=P1^2;
bit Key1Flag;
bit key2Flag;
unsigned char counter,temp;
void mian(void)
{
    LCM_DispIni();
    LCM_DispStr(2,1,"KEy1:"
    counter=0;
    while(1)
    {
        keyCheck();
        keyProcess();
    }
table1:
    dw 63628,63835,64021,64103,64260,64400,64524
    dw 64580,64680,64777,64820,64898,64968,65030
    dw 65058,65110,65157,65178,65217,65252,65283

}
搜索更多相关主题的帖子: 汇编 C语言 
2010-05-07 21:42
jcslt
Rank: 8Rank: 8
来 自:90-xx.com
等 级:蝙蝠侠
帖 子:251
专家分:975
注 册:2009-10-10
收藏
得分:20 
这是一个单片机的课程设计吧,搜索下就应该有吧!

www.
2010-05-08 00:22
快速回复:求助汇编转变成C语言!!!!!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017263 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved