BSEL

BSEL

mnemonic: bsel (VEA),b,d

 short: 

 graphic:
     input1:  (bytes l-s with their bits 7...0)
      -------------------------------------------------------------------------
      |llllllll|mmmmmmmm|nnnnnnnn|oooooooo|pppppppp|qqqqqqqq|rrrrrrrr|ssssssss|
      |76543210|76543210|76543210|76543210|76543210|76543210|76543210|76543210|
      -------------------------------------------------------------------------
       |      |                                                       |      |
       | ...  |                   ...                                 | ...  |
       |      |                                                       |      |
     input3: (contents of destination register d, with bytes d-k)     |      |
      -------------------------------------------------------------------------
      |dddddddd|eeeeeeee|ffffffff|gggggggg|hhhhhhhh|iiiiiiii|jjjjjjjj|kkkkkkkk|
      |76543210|76543210|76543210|76543210|76543210|76543210|76543210|76543210|
      -------------------------------------------------------------------------
       |      |                                                       |      |
       | ...  |                   ...                                 | ...  |
       |      |                                                       |      |
     input2: (contents of register b with bytes b,c,t-y)              |      |
      -------------------------------------------------------------------------
      |bbbbbbbb|cccccccc|tttttttt|uuuuuuuu|vvvvvvvv|wwwwwwww|xxxxxxxx|yyyyyyyy|
      |76543210|76543210|76543210|76543210|76543210|76543210|76543210|76543210|
      -------------------------------------------------------------------------
       |       \                                                      |      |
       | ...    \_________________    ...                      ______/  ...   \___
       |                          \                           /                   \
       |                           \                         /                     \
   --------------------    --------------------    --------------------    --------------------
   | (b7&l7)|(!b7&d7) | .. | (b0&l0)|(!b0&d0) | .. | (y7&s7)|(!y7&k7) | .. | (y0&s0)|(!y0&k0) |
   --------------------    --------------------    --------------------    --------------------
       |  ...   ____________________/          ...          \________   ...    ____/ 
       |       /                                                     \        /
      -------------------------------------------------------------------------
      |dddddddd|eeeeeeee|ffffffff|gggggggg|hhhhhhhh|iiiiiiii|jjjjjjjj|kkkkkkkk|
      |76543210|76543210|76543210|76543210|76543210|76543210|76543210|76543210|
      -------------------------------------------------------------------------

 equivalent C Code:
  {
   unsigned long long a;
   unsigned long long b;
   unsigned long lond d;

   d = ( d & (!b) ) | ( a & b ); /* BSEL a,b,d */
  }

 typical application cases:

  This instruction allows a bit-by-bit selection of data from two sources
  into the destination. Typically, this is applied in conjunction with a prior
  pcmp instruction. 
  
  Tasks like conditional replenishment and clipping easily come to mind.