Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "ARM Bitwise Logic. Bitwise Logic Bitwise operations : Work on patterns of bits, not values represented by those bits."— Presentation transcript:

1 ARM Bitwise Logic

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

3 Bitwise Logic Bitwise OR:

4 Binary Immediates #0b starts a binary immediate value – No spaces – Any 1’s must be in 8 consecutive bits 0b11111111 0b1111111100000000 0b0000000000010101011000 0b100000000000100

5 ORR ORR: Bitwise OR ORRrd, rs, #___ ORRrd, rs, rm

6 AND AND: Bitwise AND ANDrd, rs, #___ ANDrd, rs, rm

7 EOR EOR: Bitwise exclusive OR EORrd, rs, #___ EORrd, rs, rm

8 In Place Swap EOR can swap two values in place

9 NOT No NOT instruction – use MVN

10 Key Details 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

11 High Level Code In C/C++

12 High Level Code

13 BIC BIC: Binary Clear BICrd, rs, #___ BICrd, rs, rm – Clear bits set in # or rm – AND with invers or bits in # or rm

14 Bit Isolation Getting particular bits out of pattern Strategy 1: – Shift to wipe out others Want to clear left 8 bits: 1010 1011 1111 0110 1010 1011 1111 0110 Shift left 8 bits: 1111 0110 1010 1011 1111 0110 0000 0000 Shift back right 8 bits: 0000 0000 1111 0110 1010 1011 1111 0110

15 Bit Isolation Getting particular bits out of pattern Strategy 1: – Shift to wipe out others Want to isolate green five bits 1111 1111 1111 0110 1010 1011 1111 0110 Shift left 8 bits 1111 0110 1010 1011 1111 0110 0000 0000 Shift right 27 0000 0000 0000 0000 0000 0000 0001 1110

16 Bit Isolation Getting particular bits out of pattern Strategy 2: – Mask : binary pattern showing bits to keep 0x00 : keep no bits 0x01 : keep bit 1 (0000 0001) 0x04 : keep bit 3 (0000 0100) 0x05 : keep bit 1 & 3 (0000 0101) 0xF0 : keep bit 5-8 (1111 0000)

17 Using Masks AND with a mask 0's out unmasked portions: 0000 1111Mask0011 0000 0101 1011Data0101 1011 0000 1011AND result0001 1011

18 Hex Mask F (1111) mask a whole hex digit 0x0000000fMask0xfff00000 0x12345678Data0x12345678 0x00000008AND result0x12300000

19 Bit Isolation Getting particular bits out of pattern Strategy 2: – Masking : binary pattern showing bits to keep Want to keep just green bits 1010 1011 1111 0110 1010 1011 1010 0110 Create mask… 0x01F0 0000 0000 0000 0000 0000 0001 1111 0000 AND 0000 0000 0000 0000 0000 0001 1010 0000

20 Mask Samples


Download ppt "ARM Bitwise Logic. Bitwise Logic Bitwise operations : Work on patterns of bits, not values represented by those bits."

Similar presentations


Ads by Google