Parallel Port Access Under Win32 C++

Started by
19 comments, last by zenassem 21 years, 8 months ago
Not a problem. I''m glad you didn''t find all that condescending or anything. After I posted it I wondered if you might already have known about bit setting and retrieving, but I guess they don''t teach bitwise stuff that much any more. I didn''t find it unnerving at all.

Here is the rest of my old notes cleaned up a little so you can have a reference if you need it.


  BITWISE OPS : merging ops require data items to be of the same type (ie. have the same number of bits)operates on each corresponding bit in each data item in turn to yield a third bit in the resulting data itemeach bit is independent of the others - there is no arithmetical carry over from bit column to bit columnAND &- operates like a 2 bit truth table- if either bit is zero, yield bit is zero too- both bits must be one for the yield bit to be one   0011 & 0101   ----   0001	   FFTT  & FTFT   ----   FFFTXOR ^- bitwise exclusive OR- returns 1 when either bit but not both are 1- an XOR applied twice yields the original operand   0011 ^ 0101   ----   0110   FFTT ^ FTFT   ----   FTTFOR |- two bits ORed yield 1 if either or both bits are 1 and 0 if both bits are 0- used to combine bits from different variables into a single variable   0011 | 0101   ----   0111   FFTT | FTFT   ----   FTTTBITKEYX 0011Y 0101op==== & 0001^ 0110| 0111BITKEYX FFTTY FTFTop==== & FFFT^ FTTF| FTTT0x80 == 10000000 == 1 << 7 == 1280x40 == 01000000 == 1 << 6 ==  640x20 == 00100000 == 1 << 5 ==  32 0x10 == 00010000 == 1 << 4 ==  160x08 == 00001000 == 1 << 3 ==   80x04 == 00000100 == 1 << 2 ==   40x02 == 00000010 == 1 << 1 ==   2 0x01 == 00000001 == 1 << 0 ==   1BITWISE LEFT <<- always shifts in 0 bits from the right discarding left most bits- each bit shifted is equivalent to multiplying by 2- so shifting left 3 bits is like muliplying by 8intVar << x (places)RIGHT SHIFT >>- moves each bit in operand to the right the indicated number of places- shifting right one bit same as dividing operand by 2intVar >> x (places)- zeros are shifted from the left and the right most bit disappear- except in the case of signed types where a 1 in the left most bit indicates a negative number- 1''s are shifted in to preserve signif the signed bit is set in a signed operand, right shifts will shift 1''s in from the leftBITWISE COMPLEMENT ~ (unary)- reverses each bit- complementing a number twice returns the orginal number  
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement