Download presentation

Presentation is loading. Please wait.

1
Logical and Shift operations A particular bit, or set of bits, within the byte is set to 1 or 0 depending on conditions encountered during the execution of a program. When so used, these bits are often called "flags". Frequently, the programmer must manipulate these individual bits - an activity sometimes known as "bit twiddling". The logical and shift operations provide the means for manipulating the bits.

2
Logical operations OR Operations OR Results in 1 if either or both of the operands are 1. OR Table 0 OR 0 = 0 0 OR 1 = 1 1 OR 0 = 1 1 OR 1 = 1

3
Logical operations To perform the OR operation, take one column at a time and perform the OR operation using the OR table. Ex 1: 10010011 OR 00001111 10011111

4
Logical operations Ex 2: 11001001 OR 00001010 11001011 Ex 3: 0111 OR 0010 0111

5
Logical operations XOR Operations The exclusive OR. Similar to OR except that it gives 0 when both its operands are 1. Rules. 0 XOR 0 = 0 0 XOR 1 = 1 1 XOR 0 = 1 1 XOR 1 = 0

6
Logical operations Ex 1: 10011001 XOR 00001111 10010110 Ex 2: 0111 XOR 0010 0101

7
Logical operations NOT Operations NOT is a separate operator for flipping all bits. Rules. NOT 0 = 1 NOT 1 = 0 Example.NOT 1010 0101

8
Logical operations AND Operations AND yields 1 only if both its operands are 1. Rules. 0 AND 0 = 0 0 AND 1 = 0 1 AND 0 = 0 1 AND 1 = 1

9
Logical operations Ex 1: 11010011 AND 00001111 00000011 Ex 2: 0111 AND 1001 0001

10
Shift and Rotate operations Where as logical operations allow the changing of bit values in place, shift and rotate operations allow bits to be moved left or right without changing their values.

11
Shift and Rotate operations SHL SHL (shift left) shifts each bit one place to the left. The original leftmost bit is lost and a 0 is shifted into the rightmost position. Ex 1.SHL1101 1 1010 Ex 2.SHL1100 1000

12
Shift and Rotate operations SHR SHR (shift right) shifts each bit one place to the right. The original rightmost bit is lost and a 0 is shifted into the leftmost position. Ex 1.SHR1011 0101 1 Ex 2.SHR0011 0001

13
Shift and Rotate operations ROL ROL (rotate left) shifts each bit one place to the left. The original leftmost bit is shifted into the rightmost position. No bits are lost. Ex 1.ROL1101 1011 ROL1100 1001

14
Shift and Rotate operations ROR ROR (rotate right) shifts each bit one place to the right. The original rightmost bit is shifted into the leftmost position. No bits are lost. Ex 1.ROR1011 1101 Ex 2.ROR0011 1001

Similar presentations

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google