簡體   English   中英

將匯編語言翻譯成英語(EASy68K)

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM