当前位置:首页 > 单片机 > 单片机
[导读](1)_chkfloat_:函数定义:unsigned char _chkfloat_ ( float val); /* number to check */函数功能:_chkfloat_函数检查浮点数 val 的类型。返回值:_chkfloat_函数返回浮点数 val 的类型。返回值意义0标准浮点数

(1)_chkfloat_:

函数定义:unsigned char _chkfloat_ ( float val); /* number to check */

函数功能:_chkfloat_函数检查浮点数 val 的类型。

返回值:_chkfloat_函数返回浮点数 val 的类型。

返回值

意义

0

标准浮点数

1

浮点0

2

+INF 正溢出

3

-INF 负溢出

4

NaN 非数

/*本实验测试本征库中的_chkfloat_函数:函数定义:unsignedchar_chkfloat_(floatval);返回值:ReturnValueMeaning0Standardfloating-pointnumber.1Floating-pointvalue0.2+INF(positiveoverflow).3-INF(negativeoverflow).4NaN(NotaNumber)errorstatus.用P1指示返回值*///函数测试:#include#includeunsignedcharf[4]={0xff,0xff,0xff,0xff};voiddelay(unsignedinttime){while(time--);}voidmain(){P2=~_chkfloat_(1.2455);//Standardfloating-pointnumber.delay(50000);P2=~_chkfloat_(0.00);//Floating-pointvalue0.delay(50000);P2=~_chkfloat_(1000000000000000000000000000000000000000000000000000000000000000.0000000000);//+INF(positiveoverflow).delay(50000);P2=~_chkfloat_(-1000000000000000000000000000000000000000000000000000000000000000.0000000000);//-INF(negativeoverflow).delay(50000);P2=~_chkfloat_(*((float*)f));//NaN(NotaNumber)errorstatus.while(1);}

(2)_crol_:

函数定义:unsigned char _crol_ ( unsigned char c,unsigned char b);  /* character to rotate left */

                                    /* bit positions to rotate */

函数功能:_crol_函数将一个字节c循环左移b位。

返回值:_crol函数返回将c循环左移b位后的值。

/*本实验测试本征库中的_crol_函数函数定义:unsignedchar_crol_(unsignedcharc,unsignedcharb);返回值:_crol_函数返回将c循环左移b位后的值。用P1指示返回值*///函数测试:#include#includevoiddelay(unsignedinttime){while(time--);}voidmain(){unsignedchari;i=0;P2=~0x01;for(i=0;i<8;i++){P2=_crol_(P2,1);delay(50000);}while(1);}

(3)_cror_:

函数定义:unsigned char _cror_ ( unsigned char c, /* character to rotate right */
unsigned char b); /* bit positions to rotate */
函数功能:_cror_函数将一个字节c循环右移b位。
返回值:_cror_函数返回将c循环右移b位后的值。

/*本实验测试本征库中的_cror_函数函数定义:unsignedchar_cror_(unsignedcharc,unsignedcharb);返回值:_cror_函数返回将c循环右移b位后的值。用P1指示返回值*///函数测试:#include#includevoiddelay(unsignedinttime){while(time--);}voidmain(){unsignedchari;i=0;P2=~0x80;for(i=0;i<8;i++){P2=_cror_(P2,1);delay(50000);}while(1);}

(4)_getkey:

函数定义:char _getkey (void);

函数功能:等待接收串口的一个字节的数据。

返回值:从串口接收到的字节。

/*本实验测试标准输入输出库中的_getkey函数函数定义:char_getkey(void);返回值:从串口接收到的字节。用P1指示返回值*///函数测试:#include#includevoiddelay(unsignedinttime){while(time--);}voidUART_Init()/*通讯有关参数初始化*/{PCON&=0x7f;TH1=0xfd;/*T1usesio*/TL1=0xfd;/*选择通讯速率:0=1200,1=2400,2=4800,3=9600,4=19.2k*//*T1usesio*/TMOD=0x21;/*T1=MODE2,sio;T0=MODE1,16bit,usetime*/PS=1;/*SIOinthigh优先级*/EA=1;ET1=0;SM0=0;SM1=1;/*SM0=0SM1=1,mode1,10bit*/SM2=0;/*dataint,无校验(TB8=bit_duble偶)*/TR1=1;REN=1;RI=0;TI=0;ES=1;}voidmain(){delay(50000);UART_Init();P2=0xff;while(1){P2=_getkey();}}

(5)_irol_:

函数定义:unsigned int _irol_ ( unsigned int i, /* integer to rotate left */

unsigned char b); /* bit positions to rotate */

函数功能:对整型数i循环左移b位。

返回值:i循环左移b位后的值。

/*本实验测试本征库中的_irol_函数函数定义:unsignedint_irol_(unsignedinti,unsignedcharb);返回值:i循环左移b位后的值。*///函数测试:#include#includeunsignedinttest;voidmain(){test=0xa5a5;test=_irol_(test,3);//test=0x2d2dwhile(1);}

(6)_iror_:

函数定义:unsigned int _iror_ ( unsigned int i, /* integer to rotate right */

unsigned char b); /* bit positions to rotate */

函数功能:对整型数i循环右移b位。

返回值:i循环右移b位后的值。

/*本实验测试本征库中的_iror_函数函数定义:unsignedint_iror_(unsignedinti,unsignedcharb);返回值:i循环右移b位后的值。*///函数测试:#include#includeunsignedinttest;voidmain(){test=0xa5a5;test=_iror_(test,3);//test=0xb4b4while(1);}

(7)_lrol_:

函数定义:unsigned long _lrol_ ( unsigned long i, /* 32-bit integer to rotate left */

unsigned char b); /* bit positions to rotate */

函数功能:对长整型数i循环左移b位。

返回值:i循环左移b位后的值。

/*本实验测试本征库中的_lrol_函数函数定义:unsignedlong_lrol_(unsignedlongi,unsignedcharb);返回值:i循环左移b位后的值。*///函数测试:#include#includeunsignedlongtest;voidmain(){test=0xa5a5a5a5;test=_lrol_(test,3);//test=0x2d2d2d2dwhile(1);}

(8)_lror_:

函数定义:unsigned long _lror_ ( unsigned long i, /* 32-bit integer to rotate right */

unsigned char b); /* bit positions to rotate */

函数功能:对长整型数i循环右移b位。

返回值:i循环右移b位后的值。

/*

本实验测试本征库中的_lror_函数

函数定义:unsigned long _lror_(unsigned long i,unsigned char b);

返回值:i循环左移b位后的值。

*/

u函数测试:

#include

#inc

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭