单片机程序中“s=-crol-(s,1)"是什么意思?有没和它类似大或相反的...
发布网友
发布时间:2024-10-05 14:15
我来回答
共3个回答
热心网友
时间:2024-10-05 16:20
将S左移一位,起到乘二的作用,因为直接通过单片机来算乘除法会非常慢,因此用左移一位的方法来实现,同理_cror_(s,n)指s向右移n位
热心网友
时间:2024-10-05 16:24
变量s左移一位,相当于:s = s * 2;
上面语句也可以写作: s *= 2。
相反的语句就是_cror_,右移。
热心网友
时间:2024-10-05 16:21
#include <intrins.h>
unsigned char _crol_ (unsigned char c, /* character to rotate left */
unsigned char b); /* bit positions to rotate */
Description:
The _crol_ routine rotates the bit pattern for the character c left b bits. This routine is implemented as an intrinsic function. The code required is included in-line rather than being called.
Return Value:
The _crol_ routine returns the rotated value of c.
Attributes:
reentrant, intrinsic
See Also:
_cror_, _irol_, _iror_, _lrol_, _lror_
Example
#include <intrins.h>
void tst_crol (void) {
char a;
char b;
a = 0xA5;
b = _crol_(a,3); /* b now is 0x2D */
}