【问题标题】:Translating Assembly Language to English (EASy68K)将汇编语言翻译成英语 (EASy68K)
【发布时间】:2023-06-26 01:09:02
【问题描述】:

在课堂上给出了以下代码,并且应该在右侧的 cmets 中描述每一行的含义。这是正确的吗?

       MOVE.B  #20,D0     //Move 20 into D0
       MOVEA.L #$1000,A0  //Move the contents of address 1000 into A0 
       CLR.B   D1         //Set D1 to 0
Again  CMP.B   (A0)+,D2   //Compare A0 to D2, then increment A0 by 1
       BNE     NEXT       //If A0 and D2 are not equal, go to NEXT, otherwise continue
       ADD.B   #1,D1      //Add 1 to D1
NEXT   SUB.B   #1,D0      //Subtract 1 from D0
       BNE     Again      //Branch to AGAIN if contents of A0 is not equal to D2

【问题讨论】:

  • 你为什么不问问你的导师?
  • 如果我有导师,我会问他们。感谢您的帮助。
  • 真的吗?你有没有导师的班级?

标签: assembly easy68k


【解决方案1】:

不,这是不正确的。至少,这是:

Again  CMP.B   (A0)+,D2   //Compare A0 to D2, then increment A0 by 1

...没有将 A0 的 content 与任何东西进行比较。它将 A0 中包含的地址中的一个字节与 D2 中的一个字节进行比较(然后将 A0 递增以指向下一个地址)。

如果我没记错的话,在这些行中:

NEXT   SUB.B   #1,D0      //Subtract 1 from D0
       BNE     Again      //Branch to AGAIN if contents of A0 is not equal to D2

零标志应根据前面的sub.b 的结果设置/清除,因此它会继续进行 0x20 次迭代(因为 D0 在第一行中加载了 0x20)。

【讨论】:

  • 谢谢。这就是我的意思,但不是很清楚/不正确。