/*--------------------------------------------------------------------------
伪本征函数——Keil C51头文件INTRINS.H的扩容工程 第三版
根据HotPower的“同名小说《Keil C51红杏出墙记》”改编
2004.6.8 作于西安大雁塔村大队部
--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------
本文件名: HotIns.H
---------------------------------------------------------------------------*/
#ifndef __HotIns_H__
#define __HotIns_H__
/*------------------------------------------------------------------------*/
#define _setc_() CY = 1
#define _clrc_() CY = 0
/*------------------------------------------------------------------------*/
#define _setb_(RBIT) RBIT = 1
#define _clrb_(RBIT) RBIT = 0
/*------------------------------------------------------------------------*/
#define _clra_() ACC = 0
/*------------------------------------------------------------------------*/
#define _xorr_(RX) RX ^= RX //用于取奇偶位P,且RX=0
#define _andr_(RX) RX &= RX //用于取奇偶位P,且RX=不变
#define _orr_(RX) RX |= RX //用于取奇偶位P,且RX=不变
#define _notr_(RX) RX =~RX
/*------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------
伪本征函数——Keil C51头文件INTRINS.H的扩容工程(第二版)头文件HotIns.H扩充部分
--------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------*/
#define _rrca_() CY = ACC & 0x01 //装载代码RRC A
#define _rlca_() CY = ACC & 0x80 //装载代码RLC A
/*------------------------------------------------------------------------------------------*/
#define _rrcr_(RX) CY = RX & 0x01; RX = ACC //装载代码RRC RX
#define _rlcr_(RX) CY = RX & 0x80; RX = ACC //装载代码RLC RX
/*------------------------------------------------------------------------------------------*/
#define _movra_(RX) RX = ACC
#define _movar_(RX) ACC = RX
/*------------------------------------------------------------------------------------------*/
#define _movcb_(RBIT) CY = RBIT
#define _movbc_(RBIT) RBIT = CY
/*------------------------------------------------------------------------------------------*/
#define _movb0_(RBIT, RX) RBIT = RX & 0x01 //用于取RX的最低位
#define _movb7_(RBIT, RX) RBIT = RX & 0x80 //用于取RX的最高位
/*------------------------------------------------------------------------------------------*/
#define _movc0_(RX) CY = RX & 0x01
#define _movc7_(RX) CY = RX & 0x80
/*------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------
伪本征函数——Keil C51头文件INTRINS.H的扩容工程(第三版)头文件HotIns.H扩充部分 2004.6.8
--------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------*/
#define _icall_(ADDR) (*(void (*)())((void *)ADDR))();//通用直接或间接调用函数_icall_()声明
/*------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------*/
#define _db_(TABNAME, TAB) code unsigned char TABNAME[]={TAB}//装载数据或代码_db_()声明
/*------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------*/
sfr16 DPTR = 0x82;//声明C51标准的16位寄存器DPTR, 以便实现汇编级的命令跳转
/*-------------------------------------------------------------------------------------------*/
#define _lcall_(ADDR) DPTR = (void *)ADDR;_icall_(__ljmp_code__ + 4);//直接调用函数_lcall_()声明
#define _ljmp_(ADDR) DPTR = (void *)ADDR;_icall_(__ljmp_code__); //直接跳转函数_ljmp_()声明
_db_(__ljmp_code__, "\x15\x81\x15\x81\xc0\x82\xc0\x83\x22"); //装载数据DB 0x15..0x22
/*--------------------------------------------------------------------------------------------
装载代码 __ljmp_code__: DEC SP;//_ljmp_()函数入口,调整SP以免程序崩溃
DEC SP
PUSH DPL;//_lcall_()函数入口
PUSH DPH
RET
--------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------*/
#define _intjmp_(ADDR) DPTR = (void *)ADDR;_icall_(__reset_code__) //中断隐身函数_intjmp_()声明
#define _reset_() DPTR = __reset_code__ + 5;_icall_(__reset_code__) //软复位函数_reset_()声明
_db_(__reset_code__, "\xc0\x82\xc0\x83\x32\xe4\xc0\xe0\xc0\xe0\x32");//装载数据DB 0xc0..0x32
/*--------------------------------------------------------------------------------------------
装载代码 __reset_code__: PUSH DPL;//非典的软复位函数入口(执行2次RETI)
PUSH DPH
RETI;//_intjmp_()函数调用到此为止中断退出并跳入子程序隐身(让出中断)
CLR A;//经典的软复位函数入口(执行1次RETI)
PUSH ACC
PUSH ACC
RETI;//_reset_()函数调用从此处跳入0x0000开始执行
/*------------------------------------------------------------------------------------------*/
#define _daa_() _icall_(__daa_code__) //十进制调整函数_daa_()声明
/*------------------------------------------------------------------------------------------*/
_db_(__daa_code__, "\xd4\x22"); //装载数据DB 0xd4,0x22
/*--------------------------------------------------------------------------------------------
装载代码 __daa_code__: DA A
RET
--------------------------------------------------------------------------------------------*/
/*------------------------------------------------------------------------------------------*/
#define _swapr_(RX) ACC = RX; _swapa_(); RX = ACC; //变 量半字节交换函数_swapr_()声明
#define _swapa_() _icall_(__swapa_code__); //累加器半字节交换函数_swapa_()声明
_db_(__swapa_code__, "\xc4\x22"); //装载数据DB 0xc4,0x22
/*--------------------------------------------------------------------------------------------
装载代码 __swapa_code__: SWAP A
RET
--------------------------------------------------------------------------------------------*/
#endif |