DR. VIKAS J. DONGRE HOD ELECTRONICS & TELECOM GOVERNMENT POLYTECHNIC WASHIM (MS) EMAIL: DONGREVJ1@GMAIL.COM
Arithmetic operations • Add + • Subtract – • Multiply * • Divide / • Mod %
#include <reg51.h> void main(void) { unsigned char a,b,c; while(1) { P1=0xff; P2=0xff; a=P1; b=P2; c=a+b; P3=c; } }
Logical operations  Logical operators  AND (&&), OR (||), and NOT (!)  Bit-wise operators  AND (&), OR (|), EX-OR (^), Inverter (~), Shift Right (>>), and Shift Left (<<)  These operators are widely used in software engineering for embedded systems and control
AND OR EX-OR Inverter A B A&B A|B A^B ~B 0 0 0 0 0 1 0 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0 Bit-wise Logic Operators for C
Examples of shifting P1= 0x9A >> 3; P2= 0x77 >> 4; P0= 0x6 << 4;
Logic Operations in C #include <reg51.h> void main (void) { P0= 0x35 & 0x0F; P1= 0x04 | 0x68; P2= 0x54 ^ 0x78; P0= ~0x55; P1= 0x9A >> 3; P2= 0x77 >> 4; P0= 0x6 << 4; }
Arithmetic and logic operations in c

Arithmetic and logic operations in c

  • 1.
    DR. VIKAS J.DONGRE HOD ELECTRONICS & TELECOM GOVERNMENT POLYTECHNIC WASHIM (MS) EMAIL: DONGREVJ1@GMAIL.COM
  • 2.
    Arithmetic operations • Add+ • Subtract – • Multiply * • Divide / • Mod %
  • 3.
    #include <reg51.h> void main(void) { unsignedchar a,b,c; while(1) { P1=0xff; P2=0xff; a=P1; b=P2; c=a+b; P3=c; } }
  • 4.
    Logical operations  Logicaloperators  AND (&&), OR (||), and NOT (!)  Bit-wise operators  AND (&), OR (|), EX-OR (^), Inverter (~), Shift Right (>>), and Shift Left (<<)  These operators are widely used in software engineering for embedded systems and control
  • 5.
    AND OR EX-ORInverter A B A&B A|B A^B ~B 0 0 0 0 0 1 0 1 0 1 1 0 1 0 0 1 1 1 1 1 1 0 Bit-wise Logic Operators for C
  • 6.
    Examples of shifting P1=0x9A >> 3; P2= 0x77 >> 4; P0= 0x6 << 4;
  • 7.
    Logic Operations inC #include <reg51.h> void main (void) { P0= 0x35 & 0x0F; P1= 0x04 | 0x68; P2= 0x54 ^ 0x78; P0= ~0x55; P1= 0x9A >> 3; P2= 0x77 >> 4; P0= 0x6 << 4; }