Presentation is loading. Please wait.

Presentation is loading. Please wait.

ARM Bitwise Logic.

Similar presentations


Presentation on theme: "ARM Bitwise Logic."— Presentation transcript:

1 ARM Bitwise Logic

2 Boolean Logic Identities
A or 1 = 1 Anything or'd with 1 is 1 A or 0 = A Anything or'd with 0 is that thing A and 1 = A Anything and'd with 1 is that thing A and 0 = 0 Anything and'd with 0 is 0 A xor 1 = not(A) Xoring with 1 flips bit A xor 0 = A Xoring with 0 does nothing

3 Bitwise Logic Bitwise operations : Work on patterns of bits, not values represented by those bits

4 Bitwise Logic Bitwise OR:

5 Binary Immediates #0b starts a binary immediate value No spaces
Any 1’s must be in 8 consecutive bits 0b 0b 0b 0b

6 ORR ORR: Bitwise OR ORR rd, rs, #___ ORR rd, rs, rm

7 AND AND: Bitwise AND AND rd, rs, #___ AND rd, rs, rm

8 EOR EOR: Bitwise exclusive OR EOR rd, rs, #___ EOR rd, rs, rm

9 Fun Fact In Place Swap EOR can swap two values in place

10 NOT No NOT instruction – use MVN

11 BIC BIC: Binary Clear BIC rd, rs, #___ BIC rd, rs, rm
Clear bits set in # or rm

12 Bit Isolation Getting particular bits out of pattern Strategy 1:
Shift to wipe out others Want to clear left 8 bits: Shift left 8 bits: Shift back right 8 bits:

13 Bit Isolation Getting particular bits out of pattern Strategy 1:
Shift to wipe out others Want to isolate green five bits Shift left 8 bits Shift right

14 Bit Isolation Getting particular bits out of pattern Strategy 2:
Mask : binary pattern showing bits to keep

15 Using Masks AND with a 0 guantees 0 AND with 1, keeps other value:
Mask Data AND result

16 Hex Mask F (1111) mask a whole hex digit 0x0000000f Mask 0xfff00000
Data 0x AND result 0x

17 Other Masks Sample mask patterns: 0x00 : keep no bits
0x01 : keep bit 0 ( ) 0x04 : keep bit 2 ( ) 0x05 : keep bit 0 & 2 ( ) 0xC0 : keep bit 6-7 ( )

18 Bit Isolation Getting particular bits out of pattern Strategy 2:
Masking : binary pattern showing bits to keep Want to keep just green bits Create mask… 0x01F0 or 0b AND

19 Mask Samples

20 High Level Code In C/C++

21 High Level Code


Download ppt "ARM Bitwise Logic."

Similar presentations


Ads by Google