The logical instructions may be used to evaluate logical expressions. The program sequence in Fig. 3-50, which assumes that bits 7, 6, ... , 1, 0 in AL respectively represent the values of the logic variables X7, .... , X0, evaluates the Boolean expression

and puts the value of f in AH.

Figure 3-50 Sequence for evaluating a Boolean expression.

Data related directives, input, and other code
          MOV    BL,00110101B      ;CREATE MASKS FOR
          OR     BL,AL             ;EACH OF THE
          MOV    BH,10101000B      ;THREE MINTERMS
          OR     BH,AL             ;BY SETTING THE DON'T
          MOV    CL,01010101B      ;CARE BITS
          OR     CL,AL             ;TO 1
          XOR    BL,10111111B      ;BRANCH TO
          JZ     TRUE              ;TRUE IF ANY
          XOR    BH,11111011B      ;ONE OF THE
          JZ     TRUE              ;MINTERMS IS 1
          XOR    CL,01111101B
          JZ     TRUE
          XOR    AH,AH             ;OTHERWISE, AH IS CLEARED
          JMP    CONTINUE
TRUE:     MOV    AH,1              ;AH IS SET TO 1
CONTINUE:  .
           .
           .
Output and other code

3-9 SHIFT AND ROTATE INSTRUCTIONS

The machine code format of the shift and rotate instructions is of the form

The w-bit serves the usual purpose of identifying whether a byte or word is to be operated on by the instruction. The v-bit is set to 0 if the shift count is to be 1 and is set to 1 if the CL register contains the shift count. The three center bits in the second byte identify one of the seven possible shift or rotate instructions.

The shift instructions affect all of the condition flags and the rotate instructions affect only the CF and OF flags.

The destination operand, OPR, can have any of the 8086 addressing modes except the immediate mode. CNT can be a 1, a constant expression that evaluates to a 1, or the register designation CL. If it is CL, then the number of positions to be shifted is determined by the contents of CL.


Table of Contents | Next page | Previous page

This is page 39.