伪本征函数——Keil C51头文件INTRINS.H的应用演示(hotpower)
/*--------------------------------------------------------------------------
伪本征函数——Keil C51头文件INTRINS.H的应用演示
作者:HotPower@126.com 2004.5.16 第一版
--------------------------------------------------------------------------*/
#include "reg51.h"
#include "intrins.h"
unsigned char readdata(void)
{
unsigned char val;
for (val = 8; val > 0; val--)
{
_clrb_(TXD);
_nop_();
_movcb_(RXD);
_rrca_();
_setb_(TXD);
_nop_();
}
_movra_(val);
return val;
}
void writedata(unsigned char val)
{
_movar_(val);
for (val = 8; val > 0; val--)
{
_clrb_(TXD);
_rrca_();
_movbc_(RXD);
_setb_(TXD);
_nop_();
}
}
main()
{
unsigned char i;
/*----------------------------------
_movb0_();演示
-----------------------------------*/
i = 0x01;
_movb0_(TXD,i);
i = 0x02;
TXD = i & 0x01;
i = 0x03;
if (i & 0x01) TXD = 1;
else TXD = 0;
/*---------------------------------*/
/*----------------------------------
_movb7_();演示
-----------------------------------*/
i = 0x04;
_movb7_(RXD,i);
i = 0x05;
TXD = i & 0x80;
i = 0x06;
if (i & 0x80) TXD = 1;
else TXD = 0;
i = 0x07;
if (i >= 0x80) TXD = 1;
else TXD = 0;
/*---------------------------------*/
/*----------------------------------
_rlcar_();_movra_()组合演示
-----------------------------------*/
i = 0x08;
_setc_();
_movra_(i);
i <<= 1;
i |= 0x01;
i <<= 1;
i ++;
i += i;
i *= 2;
i ++;
/*---------------------------------*/
/*----------------------------------
_rrcar_();_movra_()组合演示
-----------------------------------*/
i = 0x09;
_setc_();
_rrcar_(i);
_movra_(i);
i >>= 1;
i |= 0x80;
/*---------------------------------*/
i = readdata();
writedata(i);
while(1);
}