【问题标题】:Transcribing assembly line code转录装配线代码
【发布时间】:2014-05-09 09:44:17
【问题描述】:
//comment or description about function of this assembly code

    MOV A,#15    /* comment about this here */
    MOV B,#23    /*comment about this here */

//add a comment here about function of next block of code

    Loop CMP A,B    /*comment here */  
    JAE LpDone    /*comment here */
    ADD A,#101    /*comment here */
    JMP Loop    /*comment here */
    LpDone NOP    /*comment here */

谁能解释一下这个程序的步骤和它们的作用? 我尝试通过跨步功能使用 Visual Studio 调试模式查看它,但不太了解它们的作用?

非常感谢您的帮助,

【问题讨论】:

  • 不要链接到你的代码截图。将代码作为文本包含在您的问题中(格式正确;例如,在每行的开头放置 4 个空格)。
  • 这适用于哪种 CPU 架构?助记符看起来像是 x86 的,但操作数不是。
  • 抱歉之前添加了图片链接,我对 Stack 论坛还很陌生。是的,这是 Intel x8086 架构。
  • 好吧,CMP A,B 不是有效的 x86 指令,因为没有任何形式的 CMP 可以接受两个内存操作数。也许AB 应该是EAXEBX,但问题中没有说。
  • 再看我的讲义,这是里面唯一提到的一段代码,虽然没有提到那里的指令集,只是显示了汇编代码。假设它们是 EAX 和 EBX 寄存器,您是否可以逐步解释它是如何工作的?

标签: visual-studio assembly x86


【解决方案1】:

这看起来像 8080 或 Z80 组件。我已经有一段时间没有做过与该处理器相关的任何事情了,所以我可能错了。这是我的解释:

MOV A,#15    /* Move number 15 to register A */
MOV B,#23    /* Move number 23 to register B */

Loop CMP A,B /* Compare A with B. Loop is a label used later */  
JAE LpDone   /* If above or equal, jump to label LpDone */
ADD A,#101   /* Add number 101 to register A */
JMP Loop     /* Jump to label Loop */
LpDone NOP   /* LpDone is label. NOP is no-operation so it does nothing. */

【讨论】:

    【解决方案2】:

    我认为前两条指令是将立即值移动到寄存器中。 下一条指令比较寄存器中的值并设置或清除标志寄存器的一些标志。 下一条指令是条件跳转,如果结果大于或等于则跳转。如果没有跳转到循环外的地址,则执行下面的加法指令。最后无条件跳转指令让我们跳回到比较指令。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-08
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 2013-06-02
      • 1970-01-01
      • 2014-10-30
      • 2020-09-02
      相关资源
      最近更新 更多