有关 _nop_

前文中,有一个叫 _nop_ 的函数,我不知道是干什么的,特意到QQ上问了问,一个哥们给了一段东西,原来叫“空指令”,作用就是占用一个CPU运算周期,呵呵,特意把原文贴上来,同时感谢那位朋友。

 

#include <intrins.h>
void _nop_ (void);
Description:
The _nop_ routine inserts an 8051 NOP instruction into the program. This routine can be used to pause for 1 CPU cycle. This routine is implemented as an intrinsic function. The code required is included in-line rather than being called.

Return Value:
None.

Attributes:
reentrant, intrinsic

See Also:
-

Example
#include <intrins.h>
#include <stdio.h>                      /* for printf */

void tst_nop (void)  {

  P1 = 0xFF;

  _nop_ ();                     /* delay for hardware */
  _nop_ ();
  _nop_ ();

  P1 = 0x00;

}

发表于 2005-08-14 22:39

评论

# 回复: 有关 _nop_ 2005-08-15 08:58:00 没脾气2x

bs u

# 回复: 有关 _nop_ 2006-08-14 10:52:00 zhu

学习了

# 回复: 有关 _nop_ 2006-08-14 22:23:00 lookyour

嗯 常用的东东 12m标准51环境下 一个nop正好1us 作延时 so方便

# 回复: 有关 _nop_ 2007-01-18 17:34:00 雨一直下(QQ654622072)

兄弟,看了你这个贴,有点收获。
不过我以前写延时是这样写的,你看看如何:
比如说一秒:
void delay(int a,int b,int c)
{int i,j,k;
for(i<0;i<a;i++)
for(j=0;j<b;j++)
for(k=0;k<c;k++);
}//时间t= ( (k*2+3)*j+3)*i+5
这个时间是精确的!但是不知道跟你那个比较,如何呢,还有那一个更适合用于单片机了,
欢迎加我QQ讨论。

# 回复: 有关 _nop_ 2007-12-27 10:58:00 k

发表评论

标题:  
署名:  
链接:
内容:
验证码: