Clear the top 16 bits in 1 ARM command

In an ARM assembly, immediate elements are encoded with an 8-bit rotated value, which means that we can only encode

(0-256)^2n.

Now my problem is that I want to clear the upper 16-bit values ​​of r0 and replace it with the half-layer saved by r1. But due to the limited range of immediate I have to do: -

bic r0, r0, #0xff000000
bic r0, r0, #0x00ff0000
add r0, r0, r1, LSL #16

Is it possible to replace two bic instructions with one instruction? 0xffff0000 is not applicable. Perhaps I should use a different logical operation to clear the upper 16-bit?

thank

EDIT: Sorry, I forgot to say that the first 16 bits of r1 are empty and I am using ARM7TDMI

+3
source share
7 answers

What about:

orr r0,r1,r0,lsl #16
mov r0,r0,ror #16

(, r1 , ). mov , .

+4

​​ARM, :

movt    r0, #0
orr     r0, r0, r1,lsl#16

. http://www.keil.com/support/man/docs/armasm/armasm_cjagdjbf.htm

, ARMv6 +, :

pkhbt   r0, r0, r1,lsl#16

. http://www.keil.com/support/man/docs/armasm/armasm_cihjedjg.htm

+5

" , r1" - , , 16 r1 ? ,

add r0, r1, r0 lsl #16
mov r0, r0 ror #16

, ror , r0 , .

+2

ARMv6 (, MPCore)

    uxth    r1, r1
    orr     r0, r1, r0, asl #16
+1

, xor .

, , 8 ? .

0

C

 (a<<16)|((short)b)

gcc

    mov     r1, r1, asl #16
    mov     r1, r1, asr #16
    orr     r0, r1, r0, asl #16

- - .

0

BFC. . n m

0

Source: https://habr.com/ru/post/1699636/


All Articles