descriptor = limit & 0x000F0000;
descriptor |= (flag << 8) & 0x00F0FF00;
descriptor |= (base >> 16) & 0x000000FF;
descriptor |= base & 0xFF000000;
I understood the fact that the and operation is used for masking certain bits. But what is OR operation used here for??? Please elaborate.
This is part of the code for creating a Global Descriptor Table.

What the code you've shown is doing is constructing
descriptorby selecting different parts of it from other boolean expressions.Notice that the constants that
(flag << 8),(base >> 16)andbaseare being ANDed with, when themselves ORed together, produce0xFFFFFFFF.The point of the OR is to say, "the first 8 bits come from
(base >> 16), the next 8 bits fromflag << 8, the next 4 fromlimit, the next 4 fromflag << 8and the last 8 frombase." So finally, descriptor looks like this:Where each comma separated variable is a hexadecimal digit, and
a,b,c, anddarelimit,(flag << 8),(base >> 16)andbaserespectively. (The commas are just there for readability, they stand for concatenation of the digits).