Free Electronic Circuits & 8085 projects

Electronic projects with circuit diagram and 8085 microprocessor projects.

Explanation of Instruction set of 8086 with free Sample Programs – BIT MANIPULATION INSTRUCTIONS1

Published on Nov 04 2009 // 8086 Instruction set, 8086 Sample programs

LOGICAL INSTRUCTIONS


  • NOT Instruction – Invert each bit of operand
  • NOT perform the bitwise complement of operand and stores the result back into operand itself.

    Syntax–NOT destination

    Example :

    NOT BX                            ;Complement contents of BX register. – DX =F038h
    NOT DX                           ;after the instruction DX = 0FC7h

    • AND Instruction – AND corresponding bits of two operands

    This Performs a bitwise Logical AND of two operands. The result of the operation is stored in the op1 and used to set the flags. AND op1, op2 To perform a bitwise AND of the two operands, each bit of the result is set to 1 if and only if the corresponding bit in both of the operands is 1, otherwise the bit in the result I cleared to 0 .

    Example :

    AND BH, CL                 ;AND byte in CL with byte in BH ;result in BH
    AND BX,00FFh             ;AND word in BX with immediate 00FFH. Mask upper byte, leave lower unchanged
    AND CX,[SI]                ; AND word at offset [SI] in data segment with word in CX register . Result in CX register and BX = 10110011 01011110
    AND BX,00FFh              ;Mask out upper 8 bits of BX. ;Result BX = 00000000 01011110 and CF =0 , OF = 0, PF = 0, SF = 0 ,ZF = 0.

    • OR Instruction – Logically OR corresponding of two operands

    OR Instruction – OR instruction perform the bit wise logical OR of two operands .Each bit of the result is cleared to 0 if and only if both corresponding bits in each operand are 0, other wise the bit in the result is set to 1.

    Syntax–- OR destination, source.

    Examples :

    OR AH, CL                         ;CL is OR’ed with AH, result in AH.
                                           ;CX = 00111110 10100101
    OR CX,FF00h                     ;OR CX with immediate FF00h result in CX = 11111111 10100101
                                           ;Upper byte are all 1’s lower bytes are unchanged.

    • XOR Instruction – Exclusive XOR destination, source

    XOR Instruction – XOR performs a bit wise logical XOR of the operands specified by op1 and op2. The result of the operand is stored in op1 and is used to set the flag.

    Syntax–- XOR destination, source.

    Example : ( Numerical )
                                           ; BX = 00111101 01101001 and CX = 00000000 11111111
    XOR BX, CX                       ;Exclusive OR CX with BX and Result BX = 00111101 10010110

    • TEST Instruction – AND operand to update flags

    TEST Instruction – This instruction ANDs the contents of a source byte or word with the contents of specified destination word. Flags are updated but neither operand is changed . TEST instruction is often used to set flags before a condition jump instruction

    Examples:

    TEST AL, BH                     ;AND BH with AL. no result is stored . Update PF, SF, ZF TEST CX, 0001H ;AND CX with immediate number
                                          ;no result is stored, Update PF,SF
    Example :

                                          ;AL = 01010001
    TEST Al, 80H                    ;AND immediate 80H with AL to test f MSB of AL is 1 or 0
                                         ;ZF = 1 if MSB of AL = 0 and AL = 01010001 (unchanged),PF = 0 , SF = 0,
                                         ;ZF = 1 because ANDing produced is 00