我需要帮助注释此代码。
我的作业规定我需要“将每一行的作用作为注释写入代码中”。
我不确定我的评论是否正确
.386
.model flat
.data
quote byte "Machines do feel",0 ; message output
message byte SIZEOF quote DUP(0),0
.code
start proc ; start of the procedure
mov esi, 0 ; value of esi is zero
mov ecx, SIZEOF quote ; stores size of the text in ecx
LP:
mov al, quote[esi]
mov message[esi],al
inc esi ; increment esi's value
loop LP ; loop
ret
start endp
end start
最佳答案
我不明白为什么注释规则仅仅因为汇编语言而显着不同。 “评论一下原因。”但是因为寄存器的名称不好,所以我们必须注释它们的用途,就像我们无法使用好名称的任何其他情况一样。
.386
.model flat
.data
quote byte "Machines do feel",0 ; message output
message byte SIZEOF quote DUP(0),0
.code
start proc
mov esi, 0 ; esi = offset counter
mov ecx, SIZEOF quote ; ecx = loop counter
LP:
mov al, quote[esi] ; Copy bytes from quote to message
mov message[esi],al
inc esi
loop LP
ret
start endp
end start
这种缩进不是惯用的,但它是一致的,所以我不会去打扰它。
但是为什么你把这个称为起点,就像它是你的入口点一样?这作为切入点没有意义。
关于assembly - 用该行的作用来注释复制循环的每一行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55459190/