[英]Translating Assembly Language to English (EASy68K)
在课堂上给了下面的代码,并在右边的注释中描述了每一行的含义。 这个对吗?
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
不,这是不正确的。 至少,这是:
Again CMP.B (A0)+,D2 //Compare A0 to D2, then increment A0 by 1
...没有将A0的内容与任何内容进行比较。 它将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)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.