我正在努力学习大会,而且,就目前而言,我几乎没有开始。我不太了解风格习惯,因为我还没有真正研究它。
我知道注释以分号开头,因为指令的结尾标有行尾字符( \ n );我看到的大多数代码示例都用空白字符分隔了分号和来自指令的注释,正如任何人所期望的那样。
global some_rnd_labl
section .data
hifive dd 0x00000005
section .text
some_rnd_labl:
mov eax, [esp+4] ; Adds the second last item in the stack...
add eax, [esp+8] ; and then the third last one.
add eax, [hifive] ; Good job, accumulator! Hi-5!
mov edx, eax ; Now store the result in dx...
ret
然而下,
是否普遍被认为是不好的做法,在指令旁边写分号,然后才把空白字符,或者只是品味/ 主观意见 ?
...
mov eax, [esp+4]; Adds the second last item in the stack...
add eax, [esp+8]; and then the third last one.
add eax, [hifive]; Good job, accumulator! Hi-5!
mov edx, eax; Now store the result in dx...
...
我问这个看似(可能)自我回答问题的原因是我熟悉C ++和Java的方式,两者都用分号结束指令并用“ // <标记内联注释/ strong>“,将评论标记与评论本身分开可能不直观和/或误导;我认为这种风格更容易阅读,但我不确定普通程序员不会因为它不常见而发现它不那么易读。
EG,你可以看到:
; Assembly code for my compiler / OS / CPU
mov eax, [esp+4]; Adds the second last item in the stack...
因为它是C ++〜对应物:
// C++ based pseudocode
// (notice how the semicolon and "//" are mashed together)
std::vector<int> stack(DEFINED_ELSEWHERE);
int
var1 = stackArray[1];// Adds the second last item in the stack...
是的,我意识到这是一个愚蠢的(显然是非客观的)问题,但我认为这仍然值得一提。