Chapter 4 - Arithmetic and Logic Instructions
Chapter 4 - Arithmetic and Logic Instructions
Chapter 4 - Arithmetic and Logic Instructions
Lecture 6
AAS
AAS adjusts the AX register after an ASCII subtraction.
BASIC LOGIC INSTRUCTIONS
AND, OR, XOR, NOT, TEST, NEG
Provide binary bit control in low-level software.
Bits can be set, cleared, or complemented.
All logic instructions affect the flag bits. The carry and overflow
flags are always cleared.
AND
Logical multiplication.
Can be used in place of a physical AND circuit (gate).
Uses any addressing mode except memory-to-memory and
segment register addressing.
Truth table
AND op1,op2 ; op1=op1 AND op2
AND
0 AND anything is always 0
Because of this property, the AND instruction is used to clear bits
of a binary number. This is called masking.
AND
AND can be used to convert ASCII coded number to binary coded
decimal by masking the left most four bits. This can convert
ASCII30H to 39H to 0-9.
Example: MOV BL, 35H ; ASCII code for 5
AND BL, 0FH ;masking BL BL=05
OR
Performs logical addition.
AKA inclusive-or function.
uses any addressing mode except segment register addressing.
Truth Table
OR op1,op2 ; op1= op1 OR op2
OR
Can be used to replace discrete OR gates.
1 OR anything is 1. This property can be used to be used to set
any bit.
With the OR instruction, an unknown number can be masked and
it’s bits explicitly set to 1.
OR
Can be used to convert BCD to ASCII coded numbers
Example: