打印

自己写的C51程序32数据,64位数据左环移程序

[复制链接]
1862|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
butlet|  楼主 | 2012-12-20 13:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
// -------------------------------------------------------------------------------------------------------------------------------------------------
//功能说明:32位数据环移
//修改时间:2012年3月1日 10:59:22
//修改说明:
// -------------------------------------------------------------------------------------------------------------------------------------------------

void data32_rol()
{
        unsigned char i,temp;        //临时值
       
        temp=0;

        for(i=0;i<4;i++)
        {
                temp=temp|_cror_( U8bit32_code[i]&0x80 , 7-i );  //取每个字节的数据的高位
                U8bit32_code[i] = U8bit32_code[i] << 1;                 //所有数据左移一位
        }
        U8bit32_code[0] = (_cror_( temp , 3 ) & 0x01 ) | U8bit32_code[0];        //将每个高位补入高字节的低位
        U8bit32_code[1] = ( temp  & 0x01 ) | U8bit32_code[1];
        U8bit32_code[2] = (_cror_( temp , 1 ) & 0x01 ) | U8bit32_code[2];
        U8bit32_code[3] = (_cror_( temp , 2 ) & 0x01 ) | U8bit32_code[3];
}
// -------------------------------------------------------------------------------------------------------------------------------------------------
//功能说明:64位循环移位
//修改时间:2012年3月13日 10:56:10
//修改说明:
// -------------------------------------------------------------------------------------------------------------------------------------------------
void data64_rol()                           //64位循环移位
{
        unsigned char i,temp;        //临时值
       
        temp=0;

        for(i=0;i<8;i++)
        {
                temp=temp|_cror_( U8bit64_code[i]&0x80 , 7-i );  //
                U8bit64_code[i] = U8bit64_code[i] << 1;                 //所有数据左移一位
        }
        temp=_crol_( temp , 1 );                        //把最高位的进位位放入最低位
        for(i=0;i<8;i++)
        {
           U8bit64_code[i] = (temp&0x01)|U8bit64_code[i];
           temp=_cror_( temp , 1 );
        }
}



相关帖子

沙发
ayb_ice| | 2012-12-20 13:43 | 只看该作者
库里有内嵌的32位循环操作吗
_lrol_,_lror_

利用这两个函数扩展一下就成了64位

使用特权

评论回复
板凳
butlet|  楼主 | 2012-12-20 14:23 | 只看该作者
ayb_ice 发表于 2012-12-20 13:43
库里有内嵌的32位循环操作吗
_lrol_,_lror_

呵呵 是有的 我的是写来循环移字节型数组的 汇编后的效率两者差不多

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3

主题

27

帖子

0

粉丝