Lab8 نسخة
Lab8 نسخة
Fourth Stage
The logic instructions: and, or, exclusive or, not, shift, rotate….
Whenever arithmetic and logic instructions execute the contents of the status flags (Sign flag, Zero
flag, Carry flag, Auxiliary flag, Parity flag and Overflow flag) change.
Arithmetic Instructions
If the CF=0, the result is positive and the destination has the result.
If the CF=1, the result is negative and the destination has the 2’s complement of the result. NOT and
INC increment instructions can be used to change it.
Arithmetic Instructions
One of the operands must be in AL . The other operand can be either in a register or in memory.
After the multiplication the result is in AX.
when operand is a byte:
AX = AL * operand.
when operand is a word:
(DX AX) = AX * operand.
Arithmetic Instructions
Arithmetic Instructions
Division instruction (DIV)
format:
DIV CL ; AL = AX / CL , AH = remainder
DIV CX ; AX = DX AX / CX , DX = remainder
Numerator must be in AL and AH must be set to zero
Denominator cannot be immediate but can be in memory or in a register.
After the division AL will have the quotient and AH will have the remainder.
when operand is a byte:
AL = AX / operand
AH = remainder (modulus)
when operand is a word:
AX = (DX AX) / operand
DX = remainder (modulus)
Arithmetic Instructions
Logic Instructions
AND Instruction
format:
MOV AX , 4
SHR AX , 1
0000 0100 0000 0010
Logic Instructions
Shift Left Instruction (SHL)
format:
MOV AX , 2
SHL AX , 1
0000 0100 0000 0010
Logic Instructions