This commit is contained in:
2023-12-29 00:57:13 +08:00
commit f11925818e
12 changed files with 495 additions and 0 deletions

26
include/intrins.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef _INTRINS_H_
#define _INTRINS_H_
/* warning: __push __pop 使用堆栈临时保存 sfr 数据,必需成对使用!
__push(x);
... // 保护代码块
__pop(x) //缺少无该语句编译不会出错,但运行错误!
*/
#define __push(x) __asm push _##x __endasm /* void _push_ (unsigned char _sfr); */
#define __pop(x) __asm pop _##x __endasm /* void _pop_ (unsigned char _sfr); */
#define _push_ __push  /*兼容 keil c51*/
#define _pop_ __pop  /*兼容 keil c51*/
/* 安全使用保护宏:
pushSfr(x);
... // 受保护代码块
popSfr(x) // 缺少无该语句编译出错,确保生成正确代码。
*/
#define pushSfr(x) do{\
__push(x)
#define popSfr(x) __pop(x);\
}while(0)
#endif //_INTRINS_H_