你遇到过的源代码中最好的注释是什么?


当前回答

许多年前,我接受了这份工作,为一个真正运行的项目提供支持 在Z80上的时间和组装(有其他方法做Z80吗??) 不管怎样,原作者是一个叫摩西的尼日利亚人。也许我应该 就此止步。 不管怎样,代码中到处都是这样的:

XRA A    ;MT

我花了好长时间才弄明白这是什么。指令本身没有其他作用 比清除蓄能器。这是一种狡猾的方法,尽管我不确定是否有 不管是不是优势。你可以这样做:

LDA 0

但也许

XRA A

节省一个字节之类的。is所做的是排他的或者是累加器本身。 当然,结果总是零。

回到MT -空(明白吗?)

这是我遇到的最好的。

其他回答

/* Emits a 7-Hz tone for 10 seconds.
  True story: 7 Hz is the resonant frequency of a
  chicken's skull cavity. This was determined
  empirically in Australia, where a new factory
  generating 7-Hz tones was located too close to a
  chicken ranch: When the factory started up, all the
  chickens died.
  Your PC may not be able to emit a 7-Hz tone. */

main()
{
    sound(7);
    delay(10000);
    nosound();
}

(Turbo C 2.0版本参考指南中的声音功能)

我喜欢GNU双utils中的一些注释。这个来自BFD som.c:

/* You'll never believe all this is necessary to handle relocations
   for function calls.  Having to compute and pack the argument
   relocation bits is the real nightmare.

   If you're interested in how this works, just forget it.  You really
   do not want to know about this braindamage.  */

这个也是:

/* Don't ask about these magic sequences.  I took them straight
   from gas-1.36 which took them from the a.out man page.  */

...

/* Keep track of exactly where we are within a particular
   space.  This is necessary as the braindamaged HPUX
   loader will create holes between subspaces *and*
   subspace alignments are *NOT* preserved.  What a crock.  */

另一个:

/* We will NOT put a fucking timestamp in the header here. Every
   time you put it back, I will come in and take it out again. ... */

从气体:

/* Yes this is ugly (storing the broken_word pointer
   in the symbol slot).  Still, this whole chunk of
   code is ugly, and I don't feel like doing anything
   about it.  Think of it as stubbornness in action.  */
/* My lawyer told me not to reveal */
//Visual Studio Bug Workaround:
//http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=101677

//To fix 'CJumpToHelper::GetInstance()' : undeclared identifier compiler errors, change the number lines below
//until the file compiles correctly. (This needs to be done anytime a change is made to this file)

    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines
    //////////////////////////////////////: There should be 1-10 of these lines

我经常看到这种情况:

// TODO make this work