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

[复制链接]
2287|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

粉丝
快速回复 在线客服 返回列表 返回顶部