assembly - 用该行的作用来注释复制循环的每一行

标签 assembly x86 masm

我需要帮助注释此代码。

我的作业规定我需要“将每一行的作用作为注释写入代码中”。

我不确定我的评论是否正确

    .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/

相关文章:

linux - 在 linux x86_64 程序集中生成一个 shell

virtualization - x86 虚拟化指令集(VT-x、AMD-V)是否有其他用途?

assembly - LNK 2001 无法解析的外部符号 _mainCRTStartup MASM

assembly - 我怎样才能让 masm 只生成机器代码?

visual-studio - 如何在 Visual Studio 2017 的 x86 程序集中使用 printf?

assembly - 是否有用于将立即字节移动到直接内存位置(不使用寄存器)的 x86 操作码?

c - 多核时钟计数器一致性

delphi - delphi XE2中如何从绝对地址读取数据

c++ - 如何以编程方式检查 CPU 上是否启用了融合乘加 (FMA) 指令?

x86 - 错误 : IBS profiling is disabled in the BIOS settings