2016-10-13 58 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 

希望那些有帮助吗?:)