You are on page 1of 6

14th February: Lecture#15: 3rd Slot

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• One of the most important and powerful features of the C language is its ability to
perform bit manipulation.
• This section describes the action of bit-wise logic operators and provides some
examples of how they are used.
• Bit-wise operators in C
• While every C programmer is familiar with the logical operators AND (&&), OR (||),
and NOT (!), many C programmers are less familiar with the bitwise operators AND
(&), OR (|), EX-OR (A), Inverter (~), Shift Right (»), and Shift Left («).
• These bit-wise operators are widely used in software engineering for embedded
systems and control; consequently, understanding and mastery of them are critical in
microprocessor-based system design and interfacing.

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• Bit-wise operators in C

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• Bit-wise shift operation in C
• There are two bit-wise shift operators in C: (1) shift right ( »), and (2) shift left («).
• Their format in C is as follows:
• data » number of bits to be shifted right
• data « number of bits to be shifted left

By, Nirav Joshi 6th Electrical, Summer 2023


4. Logical Operations
• Write an 8051 C program to monitor a switch connected to P0.0. When the switch is
pressed blink LED 10 times that is connected to P1.0

By, Nirav Joshi 6th Electrical, Summer 2023


Thank
You
Find me on:
Nirav Joshi
nirav.joshi@marwadieducation.edu.in
9909350982

You might also like