(1)_chkfloat_:
函數(shù)定義:unsigned char _chkfloat_ ( float val); /* number to check */
函數(shù)功能:_chkfloat_函數(shù)檢查浮點(diǎn)數(shù) val 的類型。
返回值:_chkfloat_函數(shù)返回浮點(diǎn)數(shù) val 的類型。
返回值
意義
0
標(biāo)準(zhǔn)浮點(diǎn)數(shù)
1
浮點(diǎn)0
2
+INF 正溢出
3
-INF 負(fù)溢出
4
NaN 非數(shù)
/*本實(shí)驗(yàn)測試本征庫中的_chkfloat_函數(shù):函數(shù)定義:unsignedchar_chkfloat_(floatval);返回值:ReturnValueMeaning0Standardfloating-pointnumber.1Floating-pointvalue0.2+INF(positiveoverflow).3-INF(negativeoverflow).4NaN(NotaNumber)errorstatus.用P1指示返回值*///函數(shù)測試:#include#include unsignedcharf[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_:
函數(shù)定義:unsigned char _crol_ ( unsigned char c,unsigned char b); /* character to rotate left */
/* bit positions to rotate */
函數(shù)功能:_crol_函數(shù)將一個(gè)字節(jié)c循環(huán)左移b位。
返回值:_crol函數(shù)返回將c循環(huán)左移b位后的值。
/*本實(shí)驗(yàn)測試本征庫中的_crol_函數(shù)函數(shù)定義:unsignedchar_crol_(unsignedcharc,unsignedcharb);返回值:_crol_函數(shù)返回將c循環(huán)左移b位后的值。用P1指示返回值*///函數(shù)測試:#include#include voiddelay(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_:
函數(shù)定義:unsigned char _cror_ ( unsigned char c, /* character to rotate right */
unsigned char b); /* bit positions to rotate */
函數(shù)功能:_cror_函數(shù)將一個(gè)字節(jié)c循環(huán)右移b位。
返回值:_cror_函數(shù)返回將c循環(huán)右移b位后的值。
/*本實(shí)驗(yàn)測試本征庫中的_cror_函數(shù)函數(shù)定義:unsignedchar_cror_(unsignedcharc,unsignedcharb);返回值:_cror_函數(shù)返回將c循環(huán)右移b位后的值。用P1指示返回值*///函數(shù)測試:#include#include voiddelay(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:
函數(shù)定義:char _getkey (void);
函數(shù)功能:等待接收串口的一個(gè)字節(jié)的數(shù)據(jù)。
返回值:從串口接收到的字節(jié)。
/*本實(shí)驗(yàn)測試標(biāo)準(zhǔn)輸入輸出庫中的_getkey函數(shù)函數(shù)定義:char_getkey(void);返回值:從串口接收到的字節(jié)。用P1指示返回值*///函數(shù)測試:#include#include voiddelay(unsignedinttime){while(time--);}voidUART_Init()/*通訊有關(guān)參數(shù)初始化*/{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優(yōu)先級(jí)*/EA=1;ET1=0;SM0=0;SM1=1;/*SM0=0SM1=1,mode1,10bit*/SM2=0;/*dataint,無校驗(yàn)(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_:
函數(shù)定義:unsigned int _irol_ ( unsigned int i, /* integer to rotate left */
unsigned char b); /* bit positions to rotate */
函數(shù)功能:對(duì)整型數(shù)i循環(huán)左移b位。
返回值:i循環(huán)左移b位后的值。
/*本實(shí)驗(yàn)測試本征庫中的_irol_函數(shù)函數(shù)定義:unsignedint_irol_(unsignedinti,unsignedcharb);返回值:i循環(huán)左移b位后的值。*///函數(shù)測試:#include#include unsignedinttest;voidmain(){test=0xa5a5;test=_irol_(test,3);//test=0x2d2dwhile(1);}
(6)_iror_:
函數(shù)定義:unsigned int _iror_ ( unsigned int i, /* integer to rotate right */
unsigned char b); /* bit positions to rotate */
函數(shù)功能:對(duì)整型數(shù)i循環(huán)右移b位。
返回值:i循環(huán)右移b位后的值。
/*本實(shí)驗(yàn)測試本征庫中的_iror_函數(shù)函數(shù)定義:unsignedint_iror_(unsignedinti,unsignedcharb);返回值:i循環(huán)右移b位后的值。*///函數(shù)測試:#include#include unsignedinttest;voidmain(){test=0xa5a5;test=_iror_(test,3);//test=0xb4b4while(1);}
(7)_lrol_:
函數(shù)定義:unsigned long _lrol_ ( unsigned long i, /* 32-bit integer to rotate left */
unsigned char b); /* bit positions to rotate */
函數(shù)功能:對(duì)長整型數(shù)i循環(huán)左移b位。
返回值:i循環(huán)左移b位后的值。
/*本實(shí)驗(yàn)測試本征庫中的_lrol_函數(shù)函數(shù)定義:unsignedlong_lrol_(unsignedlongi,unsignedcharb);返回值:i循環(huán)左移b位后的值。*///函數(shù)測試:#include#include unsignedlongtest;voidmain(){test=0xa5a5a5a5;test=_lrol_(test,3);//test=0x2d2d2d2dwhile(1);}
(8)_lror_:
函數(shù)定義:unsigned long _lror_ ( unsigned long i, /* 32-bit integer to rotate right */
unsigned char b); /* bit positions to rotate */
函數(shù)功能:對(duì)長整型數(shù)i循環(huán)右移b位。
返回值:i循環(huán)右移b位后的值。
/*
本實(shí)驗(yàn)測試本征庫中的_lror_函數(shù)
函數(shù)定義:unsigned long _lror_(unsigned long i,unsigned char b);
返回值:i循環(huán)左移b位后的值。
*/
u函數(shù)測試:
#include
#inc