Arithmentic 24
Arithmentic 24
Dr. REKHA.K.S.
Associate Professor,
Dept of CS&E,
NIE,MYSURU
Objectives
• We examine the arithmetic and logic
instructions. The arithmetic instructions
include addition, subtraction, multiplication,
division, comparison, negation, increment,
and decrement.
• The logic instructions include AND, OR,
Exclusive-OR, NOT, shifts, rotates, and the
logical compare (TEST).
Objectives
• Use arithmetic and logic instructions to
accomplish simple binary, BCD, and ASCII
arithmetic.
• Use AND, OR, and Exclusive-OR to accomplish
binary bit manipulation.
• Use the shift and rotate instructions
5-1 ADDITION, SUBTRACTION AND
COMPARISON
• The arithmetic instructions found in any
microprocessor include addition, subtraction,
and comparison.
• Addition, subtraction, and comparison
instructions are illustrated.
• Also shown are their uses in manipulating
register and memory data.
Branch related Addressing Modes
• Addition (ADD) appears in many forms in the
microprocessor.
• ADD DST,SRC
• REG,MEM
• MEM,REG
• REG,REG
• Memory,immediate
• REG,IMMEDIATE
• ADD AX,BX ; opnn1= opnd1+opnd2
Increment Addition
• The INC instruction adds 1 to any register or memory
location, except a segment register.
• The size of the data must be described by using the BYTE
PTR, WORD PTR, DWORD PTR, or QWORD PTR directives.
• INC OPR
– (DST)<-(DST)-(SRC)-(CF)
– REG,MEMORY
– MEM,MEM
– MEM,IMMEDIATE
– REG,IMMEDIATE
0006 A92F
0004 B837
--------------
0001 F0F8
Figure 5–2 Subtraction-with-borrow showing how the carry flag (C) propagates the borrow
Decrement
• DEC OPR
• DEC BYTE PTR[BX]
• DEC WORD PTR[BX]
• MOV AL,255 ; AL=0FFH (255 OR -1)
• DEC AL ;AL=0FEH (254 OR -2)
• RET
AX=03C6H
• IMUL BL
• AL = 1110 0100 = -28 DECIMAL
• BL = 0011 1011 = +59 DECIMAL
• MSB =1 NEGATIVE, SF,CF,OF=1
2048 1024 512 256 128 64 32 16 8 4 2 1
1 1 1 0 0 1 0 0=-28
0 0 1 1 1 0 1 1=59
=-1652
1111 1001 1000 1100
AX=F98CH