2016-10-13 56 views

回答

3

您需要提供更多信息以獲得最佳答案。

首先,000E0015是一個32位的值。 「前四位」可能意味着最重要的位,即導致它的0。或者它可能意味着最低的四位,即5。或者你可能意味着你輸入的是000E-這是前16位(每4位組稱爲'半字節')。

二,你期望的最終狀態是什麼?如果您在寄存器中以000E0015開頭,並且目標寄存器中有XXXXXXXX,那麼您希望它是否爲000EXXXX,並保留這些值?你確定它是000E0000嗎?或者你想讓註冊表變成0000000E?如您所述,我會假設,除非您聲明,否則您希望第二個寄存器獲得000E。在這種情況下,假設你在D0開始,要到D1:

move.l d1,d0 
swap d1 

這將首先複製整個32位寄存器D1,那麼它會掉的話。 d1將包含0015000E。如果你想清除它們,你可以使用0000FFFF和d1。如果你想讓它們包含他們以前做的任何事情,你可以先在中間寄存器中準備0000000E,然後通過與FFFF0000進行與運算來清除低位,然後用OR-從中間寄存器中取出0000000E,但我不是很確定你需要什麼。

+3

現在,它已經20年了,但不應該是'move.l d0,d1'?很確定68K使用右側的目的地。 – unwind

1

你想要的是最重要的單詞,而不是第一個4位,所以32位值的最重要的16位。有幾種方法可以做到這一點。如果你只是將這個詞作爲單詞來處理,並忽略數據寄存器中的其他內容,那麼你可以安全地使用交換。

move.l #$000E0015,d0 ; so this example makes sense :) 
move.l d0,d1 ; Move the WHOLE value into your target register 
swap d1 ; This will swap the upper and lower words of the register 

在此之後D1將包含#$ 0015000E所以如果你解決這個問題只因爲你將純粹的訪問數據寄存器的$ 000E部分的字。

move.w d1,$1234 ; Will store the value $000E at address $1234 

現在,如果你打算使用數據寄存器的其餘部分,或者用或在此將超出第1個字進行操作,你需要確保的是,上字是否清晰。你可以這樣做很輕鬆了,第一次,而不是使用交換,使用lsr.l

move.l #$000E0015,d0 ; so this example makes sense :) 
move.l d0,d1 ; Move the WHOLE value into your target register 
moveq #16,d2 ; Number of bits to move right by 
lsr.l d2,d1 ; Move Value in d1 right by number of bits specified in d2 

不能lsr.l#16使用,D1爲lsX.l的直接價值限定爲8個,但你可以在另一個寄存器中最多指定32位並執行該操作。

清潔器(恕我直言)的方式(除非您重複此操作多次)將使用AND清理交換後的寄存器。

move.l #$000E0015,d0 ; so this example makes sense :) 
move.l d0,d1   ; Move the WHOLE value into your target register 
swap d1   ; This will swap the upper and lower words of the register 
and.l #$ffff,d1  ; Mask off just the data we want 

這將從d1寄存器中刪除所有不適合邏輯掩碼的位。在d1和指定的模式中,IE位設置爲true($ ffff)

最後,我認爲可能是執行此任務的最有效和最乾淨的方式是使用clr和swap。

move.l #$000E0015,d0 ; so this example makes sense :) 
move.l d0,d1   ; Move the WHOLE value into your target register 
clr.w d1   ; clear the lower word of the data register 1st 
swap d1   ; This will swap the upper and lower words of the register 

希望那些有幫助嗎?:)