简体   繁体   English

将汇编语言翻译成英语(EASy68K)

[英]Translating Assembly Language to English (EASy68K)

Was given the following code in class and am supposed describe what each line means in comments to the right. 在课堂上给了下面的代码,并在右边的注释中描述了每一行的含义。 Is this correct? 这个对吗?

       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

No, it's not correct. 不,这是不正确的。 At the very least, this: 至少,这是:

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

...is not comparing the content of A0 to anything. ...没有将A0的内容与任何内容进行比较。 It's comparing a byte at the address contained in A0 to a byte in D2 (then incrementing A0 to point to the next address). 它将A0中包含的地址中的一个字节与D2中的一个字节进行比较(然后将A0递增以指向下一个地址)。

If I'm not mistaken, in these lines: 如果我没记错的话,请在以下行中进行:

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

The zero-flag should be set/cleared based on the result of the immediately preceding sub.b , so it's continuing for 0x20 iterations (because D0 was loaded with 0x20 in the first line). 应基于紧接在前的sub.b的结果来设置/清除零标志,因此它将继续进行0x20迭代(因为在第一行中D0加载了0x20)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM