tanchao的笔记 https://bbs.21ic.com/?230646 [收藏] [复制] [RSS]

日志

zz:NOP延时问题

已有 1211 次阅读2008-9-8 11:15 |系统分类:单片机

#define __NOP1__ asm("nop");
#define __NOP2__ __NOP1__ __NOP1__
#define __NOP4__ __NOP2__ __NOP2__
#define __NOP8__ __NOP4__ __NOP4__
#define __NOP16__ __NOP8__ __NOP8__
#define __NOP32__ __NOP16__ __NOP16__
#define __NOP64__ __NOP32__ __NOP32__
#define __NOP128__ __NOP64__ __NOP64__



#define __NOPX__(a)             \
    if ((a)&(0x01))    {__NOP1__}                    \
    if ((a)&(0x02))    {__NOP2__}                    \
    if ((a)&(0x04))    {__NOP4__}                    \
    if ((a)&(0x08))    {__NOP8__}                    \
    if ((a)&(0x10))    {__NOP16__}                    \
    if ((a)&(0x20))    {__NOP32__}                    \
    if ((a)&(0x40))    {__NOP64__}                    \
    if ((a)&(0x80))    {__NOP128__}                   


只需一条__NOPX__指令,就可实现0-255任意个nop指令,可以在Keil C和IAR中使用,但有一缺点,使用越多,占用程序空间也越多。


 


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)