BIC instruction

Hello, I have a basic question about some bit clearing in Assembly. Here is what I am trying to do below.

MOV R0, #OxFFFFFFFF   ;Load R0 with the HEX Values FFFFFFFF
BIC R0, R0, #0xBF    ;This should set bit 7 from my understanding as B is 1011 in hex

When doing the above, it puts the next value in R0 (0xFFFFFF4F). I wonder why this is?

If I make this bit, it will set the value 0xFFFFFFBF

MOV R0, #OxFFFFFFFF   ;Load R0 with the HEX Values FFFFFFFF
BIC R0, R0, #00000000000000000000000001000000b

Can someone help me understand these results?

+5
source share
3 answers

I'm curious that assembler (gas) allows you to try to move more than 8 significant bits without errors ... it just encodes mvn for you.

d6008030 <TESTFUN>:
d6008030:   e3e00000    mvn r0, #0
d6008034:   e3c000bf    bic r0, r0, #191    ; 0xbf
d6008038:   e12fff1e    bx  lr

I get 0xFFFFFF40, which is the expected response.

If you want to set bit 7, then

orr r0,r0,#0x80 ;@ (corrected from 0x70)

Or did you mean that you want to set bit 6

orr r0,r0,#0x40

if you want to delete all bits except bit 6, leaving only bit 6.

and r0,r0,#0x40

, 6, ( 6) (bic = bit clear)

bic r0,r0,#0x40

mov r0,#0xFFFFFFFF ;@ this is an interesting shortcut
mov r1,#0xFFFFFFBF ;@ might as well keep using it
bic r0,r0,r1

0x00000040,

mov r0,#0xFFFFFFFF ;@ this is an interesting shortcut
and r0,r0,#0x40

+6

, , , BIC/: BIC Rd, Rn "Rd AND NOT Rn".

, :

Rn = 00000000000000000000000001000000b = 0x40
NOT Rn = 0xFFFFFFBF = 11111111111111111111111110111111b
Rd = 0xFFFFFFFF = 11111111111111111111111111111111b
Rd AND NOT Rn = 0xFFFFFFFBF = 11111111111111111111111110111111b

, BIC Rd, # 0x40 № 7 Rd. .

, .

+2

arm-none-eabi-gcc 4.8.2 Arduino Due, .

// the results is 0xffffff40, but not 0xffffff4f
mov r2, #0xffffffff
bic r2, r2, #0xbf

.

, , @Fernando .

operand2 = 0xbf
NOT operand2 = 0xffffff40
r2 = 0xffffffff
r2 AND NOT operand2 = 0xffffff40

BIC ( Clear) AND Rn Operand2. .

0
source

All Articles