CS-401 Computer Architecture & Assembly Language Programming Lecture-12 Bits Manipulation
Lets revise the last lecture
Lets revise the last lecture.
Extended Shift num1: dd 40000 sh1 word [num1+2],1 rc1 word [num1],1 Shift Right num1: dd 40000 sh1 word [num1+2],1 rc1 word [num1],1 num1 + 2 num1
Types of Logical Operations
Bitwise Logical Operators and and performs the logical bitwise ‘and’ of two operands (byte or word) and return the result to the destination operand. A bit in the result is set if both corresponding bits of the original operands are set. Otherwise the result bit is cleared. Flags affected: C O P S Z A and ax, bx and byte [num], 5 Truth table X Y X and Y 1
Bitwise Logical Operators or performs the logical bitwise ‘Inclusive or’ of two operands (byte or word) and return the result to the destination operand. A bit in the result is set if either or both corresponding bits of the original operands are set. Otherwise the result bit is cleared. Flags affected: C O P S Z A or ax, bx or byte [num], 5 Truth table X Y X or Y 1
Bitwise Logical Operators xor xor performs the logical bitwise ‘Exclusive or’ of two operands (byte or word) and return the result to the destination operand. A bit in the result is set if the corresponding bits of the original operands contains opposite values. Otherwise the result bit is cleared. Flags affected: C O P S Z A xor ax, bx xor byte [num], 5 Truth table X Y X xor Y 1
Bitwise Logical Operators not not inverts the bits (forms the 1’s complement) of the word or byte operand. Flags affected: NONE not ax not cl not byte [num] Truth table X not X 1
Masking Bits and and al, 0x0F 1 0 1 0 1 0 1 0 AL = 0xAA 0 0 0 0 1 1 1 1 mask = 0x0F 0 0 0 0 1 0 1 0 AL = 0x0A
Masking Bits or or al, 0xF0 1 0 1 0 1 0 1 0 AL = 0xAA 1 1 1 1 0 0 0 0 mask = 0xF0 1 1 1 1 1 0 1 0 AL = 0x0A
Masking Bits xor xor al, 0xF0 1 0 1 0 1 0 1 0 AL = 0xAA 1 1 1 1 0 0 0 0 mask = 0xF0 0 1 0 1 1 0 1 0