<address id="t9rtl"><delect id="t9rtl"></delect></address>
<dl id="t9rtl"><dl id="t9rtl"><output id="t9rtl"></output></dl></dl>
<dl id="t9rtl"><output id="t9rtl"></output></dl>
<dl id="t9rtl"><output id="t9rtl"></output></dl>
<noframes id="t9rtl"><video id="t9rtl"></video><dl id="t9rtl"><video id="t9rtl"><delect id="t9rtl"></delect></video></dl>
<dl id="t9rtl"></dl>
<dl id="t9rtl"><output id="t9rtl"><delect id="t9rtl"></delect></output></dl>
<video id="t9rtl"><output id="t9rtl"><font id="t9rtl"></font></output></video><video id="t9rtl"></video>
<dl id="t9rtl"><delect id="t9rtl"></delect></dl>
<dl id="t9rtl"></dl><dl id="t9rtl"></dl><dl id="t9rtl"></dl>
<dl id="t9rtl"></dl>
<delect id="t9rtl"><delect id="t9rtl"><meter id="t9rtl"></meter></delect></delect>
<video id="t9rtl"><dl id="t9rtl"></dl></video>
<dl id="t9rtl"><delect id="t9rtl"><meter id="t9rtl"></meter></delect></dl>
<noframes id="t9rtl"><dl id="t9rtl"></dl>
<dl id="t9rtl"></dl>
<noframes id="t9rtl"><dl id="t9rtl"></dl>
<video id="t9rtl"><output id="t9rtl"><font id="t9rtl"></font></output></video>
<dl id="t9rtl"></dl>
<video id="t9rtl"><dl id="t9rtl"><delect id="t9rtl"></delect></dl></video><output id="t9rtl"></output>
專注電子技術學習與研究
當前位置:單片機教程網 >> MCU設計實例 >> 瀏覽文章

用戶函數庫之循環移動函數

作者:佚名   來源:本站原創   點擊數:  更新時間:2011年08月30日   【字體:
//////////////////////////////////////
//   循環左移/右移函數
//時   間:2011年8月29
//作   者:簡の約
//說   明:用Keil軟件調試成功!
//備注:
// -----
//  可以不用再包含#include <intrins.h>,而是用自己的函數
//版本:
// -----2011.08.29.0.1
///////////////////////////////////////

#include <reg52.h> //51系列單片機頭文件,用于SFR的聲明
#include <intrins.h>//引用_crol_();和_cror_();用到的聲明

//函數聲明
unsigned char Loop_Left(unsigned char Value,unsigned char num); //___0xAC 1010 1100 2
unsigned char Loop_Right(unsigned char Value,unsigned char num);//___0xAC 1010 1100 2

//主函數
void main(void)
{      
   unsigned char temp1,temp2;//聲明兩個變量,用于存放左移函數返回值
   unsigned char temp3,temp4;//聲明兩個變量,用于存放左移函數返回值 

   

  temp1 = Loop_Left(0xAC,2); //return: 0xB2
   temp2 = _crol_(0xAC,2);    //return: 0xB2

   temp3 = Loop_Right(0xAC,2);//return: 0x2B
   temp4 = _cror_(0xAC,2);    //return:0x2B

   

  while(1);//最后,停留在此處進行循環 
}
////////////////////////////////////////
// 循環左移函數
// 調用說明:Loop_Left(Value,num);Value:要循環的變量;num: 循環的次數
//  返 回 值:循環移動后的值
// 
////////////////////////////////////////
unsigned char Loop_Left(unsigned char Value,unsigned char num)//___0xAC 1010 1100 2
{
   unsigned char n = 0,temp = 0;
 
   n = num % 8;//大于8次,只循環其余數
 
   temp =  Value << n; //1010 1100 << 1011 0000
   Value = Value >> (8 - n);     // >>0000 0010

   temp = temp | Value;//合并數據  1011 0010 ___0xB2

 

  return temp;//返回數據
}
////////////////////////////////////////
// 循環右移函數
// 調用說明:Loop_Right(Value,num);Value:要循環的變量;num: 循環的次數
// 返 回 值:循環移動后的值
//  
////////////////////////////////////////
unsigned char Loop_Right(unsigned char Value,unsigned char num)//___0xAC 1010 1100 2
{
   unsigned char n = 0,temp = 0;

   

  n = num % 8;//大于8次,只循環其余數

     temp = Value >> n; //1010 1100 >> 0010 1011
     Value = Value << (8 - n);  //0000 0000

   temp = temp | Value;//合并數據:0010 1011 ___0x2B

 

  return temp;//返回數據 
}

////////////////////////////////////////

//  可以自己建立一個函數庫,存放自己經常用的函數。

////////////////////////////////////////
關閉窗口

相關文章

欧美日日添日日摸|亚洲日韩精品无码|欧美日韩国产中文综合二区|51免费精品国偷自产在线
<address id="t9rtl"><delect id="t9rtl"></delect></address>
<dl id="t9rtl"><dl id="t9rtl"><output id="t9rtl"></output></dl></dl>
<dl id="t9rtl"><output id="t9rtl"></output></dl>
<dl id="t9rtl"><output id="t9rtl"></output></dl>
<noframes id="t9rtl"><video id="t9rtl"></video><dl id="t9rtl"><video id="t9rtl"><delect id="t9rtl"></delect></video></dl>
<dl id="t9rtl"></dl>
<dl id="t9rtl"><output id="t9rtl"><delect id="t9rtl"></delect></output></dl>
<video id="t9rtl"><output id="t9rtl"><font id="t9rtl"></font></output></video><video id="t9rtl"></video>
<dl id="t9rtl"><delect id="t9rtl"></delect></dl>
<dl id="t9rtl"></dl><dl id="t9rtl"></dl><dl id="t9rtl"></dl>
<dl id="t9rtl"></dl>
<delect id="t9rtl"><delect id="t9rtl"><meter id="t9rtl"></meter></delect></delect>
<video id="t9rtl"><dl id="t9rtl"></dl></video>
<dl id="t9rtl"><delect id="t9rtl"><meter id="t9rtl"></meter></delect></dl>
<noframes id="t9rtl"><dl id="t9rtl"></dl>
<dl id="t9rtl"></dl>
<noframes id="t9rtl"><dl id="t9rtl"></dl>
<video id="t9rtl"><output id="t9rtl"><font id="t9rtl"></font></output></video>
<dl id="t9rtl"></dl>
<video id="t9rtl"><dl id="t9rtl"><delect id="t9rtl"></delect></dl></video><output id="t9rtl"></output>