Keil 中#include <intrins.h>里边的“_crol_和 _cror_”函数是怎么用C语言实现的?

我问这个的初衷是想把51的程序移植到AVR里边。我知道51单片机有个CY位,不知道AVR是否有。希望能有高手帮帮小弟。

第1个回答  2012-06-20
temp=_crol_(temp,1);表示temp进行循环左移若原为11111110移后为11111101
temp=_crol_(temp,1);表示temp进行循环右移若原为01111111移后为10111111本回答被网友采纳
第2个回答  2012-06-14
#include<reg52.h>
#include <intrins.h>
#define uint unsigned int
#define uchar unsigned char
uchar temp,num,num1;
sbit beep=P2^3;
void delay(uint);

void main()
{

temp=0xfe;
while(1)
{
for(num1=0;num1<3;num1++)
{
for(num=0;num<8;num++)
{
P1=temp;
beep=0;
delay(100);
temp=_crol_(temp,1);
P1=0xff;
beep=1;
delay(100);
}
}
for(num1=0;num1<3;num1++)
{
for(num=0;num<8;num++)
{
P1=temp;
beep=0;
delay(100);
temp=_cror_(temp,1);
P1=0xff;
beep=1;
delay(100);
}
}
while(1);
}
}

void delay(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}追问

我是要实现CROR和CROL的功能而不是怎么使用。我知道怎么使用这两函数。

第3个回答  2017-11-20
好吧,我都是直接用(右移temp>>=1;左移temp<<=1;)一条语句就搞定的事情,不用那么复杂,保证能用
第4个回答  2012-06-13
debug的时候看能否跟进去? 不过一般情况下,可能不是C写的追问

我想从51移植到AVR中,51没有debug吧?

相似回答