简体   繁体   English

如何在ARM汇编中移位字节

[英]How to shift bytes in ARM assembly

Say I have the following hex values stored in registers; 假设我将以下十六进制值存储在寄存器中;

r1 = #0x1 r1 =#0x1

r2 = #0x2 r2 =#0x2

r3 = #0x3 r3 =#0x3

r4 = #0xA r4 =#0xA

And I want to store #0x123A in r0. 我想将#0x123A存储在r0中。

Is there a way of shifting byte values similar to shifting bits with LSL/LSR so that I could AND each register (r1-r4) with a mask and then shift the bytes into correct position in r0? 有没有一种方法可以像使用LSL / LSR来移位字节值那样移位字节值,以便我可以使用掩码对每个寄存器(r1-r4)进行AND操作,然后将字节移位到r0中的正确位置?

ARM shifts are done as part of the second operand in other operations. ARM移位是其他操作中第二个操作数的一部分。 So you would do something like: 因此,您将执行以下操作:

OR r0, r4, r3, LSL #4
OR r0, r0, r2, LSL #8
OR r0, r0, r1, LSL #12

though this does not do the 'mask' part if the other bits of your source registers are non-zero. 但是,如果源寄存器的其他位不为零,则此操作不会执行“掩码”部分。

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

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