You are on page 1of 29

PRESENTATION

ON
MICROPROCESSOR
PRESENTATION TOPIC : ARITHMETIC AND LOGIC INSTRUCTIONS
SUBMITTED TO : TANJIA CHOWDHURY
SUBMITTED BY : RONY NATH
ID : 666-48-02
INTRODUCTION

 The arithmetic instructions include addition,


subtraction, multiplication, division, comparison,
negation, increment and decrement.

 Thelogic instructions include AND, OR, XOR,


NOT, Shifts, Rotates and the logical compare
(TEST).
ADDITION
 Addition(ADD) appears in many forms in the
microprocessor.
A second form of addition, called add-with-
carry, is introduced with the ADC instruction.
 The
only types of addition not allowed are
memory-to-memory & segment register.
 Increment or INC is a special type of addition.
REGISTER AND IMMEDIATE
ADDITION
Register Addition Immediate Addition
 When arithmetic & logic
instructions execute , the
 Immediate addition is
interrupt, trap and other flags do employed whenever
not change. constant or known data
 Sign, zero, carry, parity & are added.
overflow flags modify with
ADD instruction  Ex: ADD DL , 33H
 Ex: ADD AL , BL
AL = AL + BL
MEMORY-TO-REGISTER AND ARRAY
ADDITION
Memory-To-Register Addition Array Addition
 Moves memory data to  Sequential lists of data.
be added to the AL (and  A sequence of instructions
other) register. written 80386 shows
 Ex: ADD DL , [ DI ] scaled-indexed from
addressing to add elements
3, 5 & 7 of an area of
memory called ARRAY.
ADDITION-WITH-CARRY

 ADC adds the bit in the carry flag (C) to the operand
data.
 Addition-with-carry showing how the carry flag (C)
links the two 16-bit additions into one 32-bit addition.
SUBTRACTION

 Many forms of subtraction (SUB) appear in the instruction


set.
 Use any addressing mode with 8, 16 or 32 bit data.
 Decrement or DEC is a special type, subtracts 1 from any
register or memory location.
 Ex: SUB CL , BL CL = CL – BL.
 Different types of subtraction: Register subtraction,
Immediate subtraction, Decrement subtraction.
SUBTRACTION-WITH-BORROW

 Subtraction-with-borrow showing how the carry


flag (C) propagates the borrow.
COMPARISON

 The comparison instruction (CMP) is a subtraction


that changes only the flag bits.
- Destination operand never changes.
 Ex: CMP CL , BL CL – BL
but SUB CL , BL CL = CL – BL.
 CMP instruction is a special form of the SUB
instruction.
MULTIPLICATION
 The MUL (unsigned) & IMUL (signed) instructions exist to
perform 8, 16 or 32 bit multiplication.
 Some flag bits overflow, carry change when the multiply
instruction executes.
 EX: MUL CL AL is multiplied by CL ; the unsigned product
is in AX.
DIVISION

 Occurs on 8, 16 & 32 bit numbers depending on microprocessor.


IDIV (signed) or DIV (unsigned).
 Division is always performed on a double-width division.
 Two types of errors: attempt to divide by zero & other is a divide
overflow.
 EX: DIV CL
BCD AND ASCII ARITHMETIC

 The microprocessor allows arithmetic manipulation of


both BCD and ASCII data.
 BCD two arithmetic techniques operate: DAA & DAS.
 ASCII arithmetic instructions function with coded
numbers , value 30H to 39H for 0-9.
 Four instructions: AAA , AAS , AAM , AAD.
 Use AX as the source & Destination register.
BASIC LOGIC INSTRUCTIONS ( AND )

 The AND instruction performs logical multiplication (the AND operation).


 Use MASK to clear some bits.
 EX: AND AL , BL
AL = AL and BL.
BASIC LOGIC INSTRUCTIONS ( OR )

 The OR instruction generates the logical sum (OR operation).


 Use MASK to set some bits.
 EX: OR AL , BL
AL = AL or BL.
BASIC LOGIC INSTRUCTIONS ( XOR )

 The X-OR instruction performs the XOR operation.


 Use MASK to invert some bits.
 EX: XOR CH , DL
CH = CH xor DL.
BASIC LOGIC INSTRUCTIONS

 Test Instruction
 Operate as AND operation.
 Does not affect the destination operand.
 Only affect the flags, mainly the zero flags.
 Usually followed by the JZ/JNZ instructions.
 EX: TEST DL , DH
DL is ANDed with DH.
 Compare to CMP instruction:
BASIC LOGIC INSTRUCTIONS
NOT AND NEG

 The NOT instruction 1’s complements a number.


 The NEG (negate) instruction 2’s complements a
number.
 The NOT function is considered logical.
 The NEG function is considered an arithmetic
operation.
SHIFT

 Position or move numbers to the left or right within


a register or memory location.
- also perform simple arithmetic as multiplication by
powers of (2+n) left shift and division by powers of
(2-n) right shift.
 Thereare 4 shift instructions. Two are logical shifts
& two are arithmetic shifts.
SHIFT

 FIGURE: The shift instructions showing the


operation and direction of the shift.
SHIFT INSTRUCTION:SHL AND SAL
SHIFT INSTRUCTION:SAR
SHIFT INSTRUCTION:SHR
SHIFT AND ROTATE INSTRUCTION
THE ROTATE INSTRUCTIONS SHOWING THE
DIRECTION AND OPERATION OF EACH ROTATE
ROTATE INSTRUCTION:ROL
ROTATE INSTRUCTION:ROR
ROTATE INSTRUCTION:RCL
ROTATE INSTRUCTION:RCR
THANK YOU FOR LISTENING

You might also like