Al - Boolean
Al - Boolean
Language
Boolean Instructions
Boolean Operators
Boolean Operators
AND Affects the status register
OR Affects the status register
XOR Affects the status register
NOT Will have no effects on the status register
Boolean Instructions
The AND Instruction
The AND instruction performs a boolean AND operation using
two 8-bits or 16-bits operand and places the result in the
destination operand.
Syntax:
AND destination, source
The operands must be of the same size and only one
of them may be a memory operand.
AND ; if 1 is ANDed with 1 = 1
; if zero ANDed with another zero or a 1 = 0
Boolean Instructions
The AND Instruction
Example:
MOV BL, 3A
MOV CL, A3
AND BL, CL
Thus;
BL: 0011 1010
CL: 1010 0011
BL: 0010 0010 22h
Boolean Instructions
The OR Instruction
The OR instruction performs a boolean OR operation using
the source and destination operands and places the result
in destination.
Syntax:
OR destination, source
The operands must be of the same size, and only
one of them may be a memory operand.
OR ; when a 1 is ORed with another 1 or zero = 1
; when a zero is ORed with a zero = 0
Boolean Instructions
The OR Instruction
Example:
MOV BL, 3A
MOV CL, A3
OR BL, CL
Thus:
BL: 0011 1010
CL: 1010 0011
BL: 1011 1011 BBh
Boolean Instructions
The XOR Instruction
The XOR (exclusive OR) instruction performs a boolean
XOR operation using the source and destination operands
and places the result in destination.
Syntax:
XOR destination, source
Only one operand may be a memory operand.
XOR ; when both are of a different bit = 1
; when both are of the same bit = 0
Boolean Instructions
The XOR Instruction
Example:
MOV BL, 3A
MOV CL, A3
XOR BL, CL
Thus;
BL: 0011 1010
CL: 1010 0011
BL: 1001 1 001 99h
Boolean Instructions
The NOT Instruction
The NOT instruction reverses all bits in an
operand, changing ones to zeros and vice versa.
The result is called the 1’s complement.
Syntax:
NOT source
The source can only be either register or
memory operand.
Boolean Instructions
The NOT Instruction
Example:
MOV BL, 3A
NOT BL
Thus;
BL: 0011 1010
BL: 1100 0101 C5h
Boolean Instructions
The NOT Instruction
The NOT instruction can be used to create two’s complement
of a number by using it with the INC instruction.
Example:
MOV AL, 01
NOT AL
INC AL
Thus;
AL: 0000 0001
AL:1111 1110
AL: 1111 1111 FFh
Boolean Instructions
The NEG Instruction
The NEG instruction negates or finds the two’s
complement of a byte or word. It takes a single
(destination) operand and negates it.
Syntax:
NEG destination
The destination can either be register or
memory.
This instruction effectively reverses the sign
of the destination operand.
Boolean Instructions
The NEG Instruction can’t take an immediate
value/ data as destination.
This instruction effectively reverses the sign of
the destination operand. If positive
negative,
negative positive
Example:
MOV ah, 04 ; AH= 04
NEG ah ; AH= FC