SlideShare a Scribd company logo
Arithmetic Instructions
INC & DEC Instructions
• Syntax:
– INC operand ; operand=operand+1
– DEC operand ; operand=operand-1
• Operand can be a general register or memory.
• INC and DEC instructions affect all the flags.
• Examples:
– INC AX legal
– DEC BL legal
– INC [BX] illegal
– INC Byte PTR [BX] legal
– DEC I legal
– INC DS illegal
NEG instruction
• Syntax: NEG operand
– Operand 0 – operand
• Finds the two’s complement of operand.
• Operand can be a general register or memory location.
• NEG instruction affects all flags.
• Examples:
– Let AX=FFF0h and I=08h
– NEG AX ; AX0010
– NEG AH ; AH01
– NEG I ; IF8
CMP instruction
• Syntax: CMP operand1, operand2
– Operand1-operand2
• Subtracts operand2 from operand1 and
updates the flags based on the result.
• CMP instruction affects all the flags.
yesnoyesMemory
Location
yesyesyesGeneral
Register
ConstantMemory
Location
General
Register
ADC and SBB instruction
• Syntax:
– ADC destination, source ; destination=destination+source+CF
– SBB destination, source ; destination=destination-source-CF
• Achieve double-precision addition/subtraction.
• To add or subtract 32-bit numbers
– Add or subtract lower 16 bits
– Add or subtract higher 16 bits with carry or borrow
• Example:
Multiplication
• Unsigned multiplication: MUL operand
• Signed multiplication: IMUL operand
• If operand is a Byte
– MUL operand; AX AL * operand
• If operand is a Word
– MUL operand; DX:AX  AX * operand
• Operand can be a general register or memory.
Cannot be a constant.
• Only CF and OF are affected.
Multiplication – Cont.
• CF=OF=0
– Unsigned multiplication: if upper half of result is 0.
– Signed multiplication: if upper half of result is a sign
extension of lower half.
• Example: Let AX=FFFFh and BX=0002h
– MUL BL; AX01FEh (255 * 2 = 510) CF=OF=1
– IMUL BL; AXFFFEh (-1 * 2 = -2) CF=OF=0
– MUL AL; AXFE01 (255 * 255 = 65025) CF=OF=1
– IMUL AL; AX0001 (-1 * -1 = 1) CF=OF=0
– MUL BX; DX0001 AXFFFE CF=OF=1
– IMUL BX; DXFFFF AXFFFE CF=OF=0
Application: Inputting a Decimal
Number
• Inputting a 2-digit decimal number
MOV AH, 1 ;read first digit
INT 21H
SUB AL, ‘0’ ; convert digit from ASCII code to binary
MOV BL, 10
MUL BL ; multiply digit by 10
MOV CL, AL
MOV AH, 1 ; read 2nd digit
INT 21H
SUB AL, ‘0’ ; convert digit from ASCII code to binary
ADD AL, CL ; AL contains the 2-digit number
Division
• Unsigned division: DIV operand
• Signed division: IDIV operand
• If operand is a Byte
– DIV Operand ; AX  AX/operand
– AH= Remainder, AL= Quotient
• If operand is a Word
– DIV Operand ; DX:AX  DX:AX/operand
– DX=Remainder, AX= Quotient
• Operand can be a general register or memory. Cannot
be a constant.
• All flags are undefined.
Division - Cont.
• Divide Overflow
– If quotient is too big to fit in specified destination (AL or AX)
– Happens if divisor much smaller than dividend
– Program terminates and displays “Divide Overflow”
• Example: Let DX=0000h, AX=0005h, and BX=FFFEh
– DIV BX; AX=0000 DX=0005
– IDIV BX; AX=FFFE DX=0001
• Example: Let DX=FFFFh, AX=FFFBh, and BX=0002h
– IDIV BX; AX=FFFE DX=FFFF
– DIV BX; DIVIDE Overflow
• Example: Let AX=00FBh (251), and BL=FFh
– DIV BL; AH=FB AL=00
– IDIV BL; DIVIDE Overflow
Application: Outputting a Decimal
Number
• Outputting a 2-digit decimal number in AX
MOV BL, 10
DIV BL ; getting least significant digit
ADD AH, ‘0’ ; converting L.S. digit to ASCII
MOV DH, AH ; storing L.S. digit temporarily
MOV AH, 0
DIV BL ; getting most significant digit
ADD AH, ‘0’ ; converting M.S. digit into ASCII
MOV DL, AH ; displaying M.S. digit
MOV AH, 2
INT 21H
MOV DL, DH ; displaying least significant digit
INT21H
Logic Instructions
• The AND, OR, and XOR instructions perform
named bit-wise logical operation.
• Syntax:
– AND destination, source
– OR destination, source
– XOR destination, source
10101010
AND 11110000
---------------
10100000
10101010
OR 11110000
---------------
11111010
10101010
XOR 11110000
---------------
01011010
Logic Instructions - Cont.
• AND instruction used to clear specific destinations bits
while preserving others.
– A 0 mask bit clears corresponding destination bit
– A 1 mask bit preserves corresponding destination bit
• OR instruction used to set specific destinations bits
while preserving others.
– A 1 mask bit sets corresponding destination bit
– A 0 mask bit preserves corresponding destination bit
• XOR instruction used to complement specific
destinations bits while preserving others.
– A 1 mask bit complements corresponding destination bit
– A 0 mask bit preserves corresponding destination bit
Logic Instructions - Cont.
• Effect on flags
– SF, ZF, PF change based on result
– AF undefined
– CF=OF=0
• Examples:
– Converting ASCII digit to a number
– SUB AL, 30h
– AND AL, 0Fh
– Converting a lowercase letter to uppercase
– SUB AL, 20h
– AND AL, 0DFh
– Initializing register with 0
– XOR AL, AL
Logic Instructions - Cont.
• NOT instruction
– performs one’s complement operation on destination
– Syntax: NOT destination
– has no effect on flags.
• TEST instruction
– performs an AND operation of destination with source but
does not change destination
– it affects the flags like the AND instruction
– used to examine content of individual bits
• Example
– To test for even numbers
– TEST AL, 1; if ZF=1, number is even
Shift Instructions
Shift Instructions can be classified as:
• Logical shift
• Arithmetic shift
Four (4) types of Shift instructions direction:
• Shift logical left (SHL)
• Shift logical right (SHR)
• Shift arithmetic left (SAL)
• Shift arithmetic right (SAR)
• Syntax:
– Opcode destination, 1 ; for single-bit shift or rotate
– Opcode destination, CL ; for shift or rotate of N bits
• SHL ( Shift Logical Left ) and SAL ( Shift Arithmetic Left ) are
two different mnemonics but perform the same operation.
• Execute the following instructions and
determine the status of the flags.
Multiplication & Division by Shift
• Multiplication by left shift
– A left shift by 1 bit doubles the destination value, i.e.
multiplies it by 2.
• Division by right shift
– A right shift by 1 bit halves it and rounds down to the
nearest integer, i.e. divides it by 2.
• Example: Multiply signed content of AL by 17
– MOV AH, AL
– MOV CL, 4
– SAL AL, CL ; AL= 16*AL
– ADD AL, AH; AL=16*AL + AL = 17 AL
QUIZ
• Determine the next value of AL after the execution.
1.
MOV AL, AAH
MOV CL,06H
SHL AL,CL
2.
MOV AL, 6BH
MOV CL, 06H
SHR AL,CL
Ans:
1. AL = 80H
2. AL = 01H
3. AL =1FH
3.
MOV AL,93H
MOV CL,03H
SHL AL,CL
SAR AL,CL
SHR AL,CL
ROTATE Instruction
• The different types of rotate instruction are:
– ROL: rotate left
– ROR: rotate right
– RCL: rotate left with carry
– RCR: rotate right with carry
QUIZ

More Related Content

What's hot

Shift rotate
Shift rotateShift rotate
Shift rotate
fika sweety
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
Ravi Anand
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
John Cutajar
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
Education
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
Kartik Sharma
 
15CS44 MP & MC Module 1
15CS44 MP & MC Module 115CS44 MP & MC Module 1
15CS44 MP & MC Module 1
RLJIT
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)
Irfan Anjum
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086aviban
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly language
warda aziz
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly languageMir Majid
 
8086 addressing modes
8086 addressing modes8086 addressing modes
8086 addressing modes
j4jiet
 
Instruction formats-in-8086
Instruction formats-in-8086Instruction formats-in-8086
Instruction formats-in-8086
MNM Jain Engineering College
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
warda aziz
 
Byte and string manipulation 8086
Byte and string manipulation 8086Byte and string manipulation 8086
Byte and string manipulation 8086
mpsrekha83
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
Badrul Alam
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Bilal Amjad
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructions
warda aziz
 
Sequential circuits in digital logic design
Sequential circuits in digital logic designSequential circuits in digital logic design
Sequential circuits in digital logic design
Nallapati Anindra
 

What's hot (20)

Shift rotate
Shift rotateShift rotate
Shift rotate
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
 
assembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YUassembly language programming and organization of IBM PC" by YTHA YU
assembly language programming and organization of IBM PC" by YTHA YU
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
 
15CS44 MP & MC Module 1
15CS44 MP & MC Module 115CS44 MP & MC Module 1
15CS44 MP & MC Module 1
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly language
 
8086 assembly language
8086 assembly language8086 assembly language
8086 assembly language
 
8086 addressing modes
8086 addressing modes8086 addressing modes
8086 addressing modes
 
Instruction formats-in-8086
Instruction formats-in-8086Instruction formats-in-8086
Instruction formats-in-8086
 
Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086Multiplication & division instructions microprocessor 8086
Multiplication & division instructions microprocessor 8086
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
 
Byte and string manipulation 8086
Byte and string manipulation 8086Byte and string manipulation 8086
Byte and string manipulation 8086
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
 
chapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructionschapter 7 Logic, shift and rotate instructions
chapter 7 Logic, shift and rotate instructions
 
Sequential circuits in digital logic design
Sequential circuits in digital logic designSequential circuits in digital logic design
Sequential circuits in digital logic design
 

Viewers also liked

Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Jay Patel
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
Robert Almazan
 
1.arithmetic & logical operations
1.arithmetic & logical operations1.arithmetic & logical operations
1.arithmetic & logical operations
mukesh bhardwaj
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
Learn By Watch
 
Logical instruction of 8085
Logical instruction of 8085Logical instruction of 8085
Logical instruction of 8085
vishalgohel12195
 
logic shift and rotate instruction
logic shift and rotate instructionlogic shift and rotate instruction
logic shift and rotate instruction
JiaahRajpout123
 
Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085
Chinmayee samal
 
Logical and shift micro operations
Logical and shift micro operationsLogical and shift micro operations
Logical and shift micro operations
Sanjeev Patel
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Frankie Jones
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller NotesDr.YNM
 
8051 experiments1
8051 experiments18051 experiments1
8051 experiments1
tt_aljobory
 
Instruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSEInstruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSE
salmancreation
 
Abelardo Alaan profile
Abelardo Alaan profileAbelardo Alaan profile
Abelardo Alaan profileAbelardo Alaan
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programming
Kartik Sharma
 
Software AND its Types & CASE toolS
Software  AND     its   Types   &    CASE toolSSoftware  AND     its   Types   &    CASE toolS
Software AND its Types & CASE toolS
kashif Shafqat
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
Nora Youssef
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperationsNitesh Singh
 

Viewers also liked (20)

Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
1.arithmetic & logical operations
1.arithmetic & logical operations1.arithmetic & logical operations
1.arithmetic & logical operations
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
arithmetic ins in 8051
arithmetic ins in 8051arithmetic ins in 8051
arithmetic ins in 8051
 
Logical instruction of 8085
Logical instruction of 8085Logical instruction of 8085
Logical instruction of 8085
 
logic shift and rotate instruction
logic shift and rotate instructionlogic shift and rotate instruction
logic shift and rotate instruction
 
Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085Addressing mode & data transfer instruction of 8085
Addressing mode & data transfer instruction of 8085
 
Logical and shift micro operations
Logical and shift micro operationsLogical and shift micro operations
Logical and shift micro operations
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
 
8051 Microcontroller Notes
8051 Microcontroller Notes8051 Microcontroller Notes
8051 Microcontroller Notes
 
8051 experiments1
8051 experiments18051 experiments1
8051 experiments1
 
Instruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSEInstruction Set Of 8086 DIU CSE
Instruction Set Of 8086 DIU CSE
 
Abelardo Alaan profile
Abelardo Alaan profileAbelardo Alaan profile
Abelardo Alaan profile
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programming
 
Microprocessor systems (4)
Microprocessor systems (4)Microprocessor systems (4)
Microprocessor systems (4)
 
Software AND its Types & CASE toolS
Software  AND     its   Types   &    CASE toolSSoftware  AND     its   Types   &    CASE toolS
Software AND its Types & CASE toolS
 
Assembly Language -I
Assembly Language -IAssembly Language -I
Assembly Language -I
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperations
 

Similar to Arithmetic and logical instructions set

Chap3 8086 logical
Chap3 8086 logicalChap3 8086 logical
Chap3 8086 logical
HarshitParkar6677
 
Chapter3 8086inst logical 2
Chapter3 8086inst logical 2Chapter3 8086inst logical 2
Chapter3 8086inst logical 2
HarshitParkar6677
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
NishatNishu5
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
HarshitParkar6677
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
HarshitParkar6677
 
8086inst logical
8086inst logical8086inst logical
8086inst logical
HarshitParkar6677
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
ihsanjamil
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
HarshitParkar6677
 
Instruction types
Instruction typesInstruction types
Instruction types
JyotiprakashMishra18
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
Mahalakshmiv11
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
logesh waran
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instruction
kashif Shafqat
 
Assembly language-lab9
Assembly language-lab9Assembly language-lab9
Assembly language-lab9
AjEcuacion
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
RLJIT
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
HarshitParkar6677
 
Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
HarshitParkar6677
 
8086 ins2 math
8086 ins2 math8086 ins2 math
8086 ins2 math
HarshitParkar6677
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
8086 microprocessor assembler directives.ppt
8086   microprocessor assembler directives.ppt8086   microprocessor assembler directives.ppt
8086 microprocessor assembler directives.ppt
NaveenKumar5162
 

Similar to Arithmetic and logical instructions set (20)

Chap3 8086 logical
Chap3 8086 logicalChap3 8086 logical
Chap3 8086 logical
 
Chapter3 8086inst logical 2
Chapter3 8086inst logical 2Chapter3 8086inst logical 2
Chapter3 8086inst logical 2
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
 
8086inst logical
8086inst logical8086inst logical
8086inst logical
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
Instruction types
Instruction typesInstruction types
Instruction types
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
Hemanth143
Hemanth143 Hemanth143
Hemanth143
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instruction
 
Assembly language-lab9
Assembly language-lab9Assembly language-lab9
Assembly language-lab9
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
 
Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
 
8086 ins2 math
8086 ins2 math8086 ins2 math
8086 ins2 math
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
8086 microprocessor assembler directives.ppt
8086   microprocessor assembler directives.ppt8086   microprocessor assembler directives.ppt
8086 microprocessor assembler directives.ppt
 

More from Robert Almazan

Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)
Robert Almazan
 
Flag control
Flag controlFlag control
Flag control
Robert Almazan
 
Week 5 lan topology
Week 5 lan topologyWeek 5 lan topology
Week 5 lan topology
Robert Almazan
 
Week 5 lan topology part 2
Week 5 lan topology part 2Week 5 lan topology part 2
Week 5 lan topology part 2
Robert Almazan
 
Week 4 introducing network standards
Week 4 introducing network standardsWeek 4 introducing network standards
Week 4 introducing network standards
Robert Almazan
 
Week 3 basic network media
Week 3 basic network mediaWeek 3 basic network media
Week 3 basic network media
Robert Almazan
 
Week 2 network configurartion
Week 2 network configurartionWeek 2 network configurartion
Week 2 network configurartion
Robert Almazan
 
introduction to networking
introduction to networkingintroduction to networking
introduction to networking
Robert Almazan
 

More from Robert Almazan (8)

Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)Distruct week 15 graphs theory (updated)
Distruct week 15 graphs theory (updated)
 
Flag control
Flag controlFlag control
Flag control
 
Week 5 lan topology
Week 5 lan topologyWeek 5 lan topology
Week 5 lan topology
 
Week 5 lan topology part 2
Week 5 lan topology part 2Week 5 lan topology part 2
Week 5 lan topology part 2
 
Week 4 introducing network standards
Week 4 introducing network standardsWeek 4 introducing network standards
Week 4 introducing network standards
 
Week 3 basic network media
Week 3 basic network mediaWeek 3 basic network media
Week 3 basic network media
 
Week 2 network configurartion
Week 2 network configurartionWeek 2 network configurartion
Week 2 network configurartion
 
introduction to networking
introduction to networkingintroduction to networking
introduction to networking
 

Recently uploaded

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 

Arithmetic and logical instructions set

  • 2. INC & DEC Instructions • Syntax: – INC operand ; operand=operand+1 – DEC operand ; operand=operand-1 • Operand can be a general register or memory. • INC and DEC instructions affect all the flags. • Examples: – INC AX legal – DEC BL legal – INC [BX] illegal – INC Byte PTR [BX] legal – DEC I legal – INC DS illegal
  • 3. NEG instruction • Syntax: NEG operand – Operand 0 – operand • Finds the two’s complement of operand. • Operand can be a general register or memory location. • NEG instruction affects all flags. • Examples: – Let AX=FFF0h and I=08h – NEG AX ; AX0010 – NEG AH ; AH01 – NEG I ; IF8
  • 4. CMP instruction • Syntax: CMP operand1, operand2 – Operand1-operand2 • Subtracts operand2 from operand1 and updates the flags based on the result. • CMP instruction affects all the flags. yesnoyesMemory Location yesyesyesGeneral Register ConstantMemory Location General Register
  • 5. ADC and SBB instruction • Syntax: – ADC destination, source ; destination=destination+source+CF – SBB destination, source ; destination=destination-source-CF • Achieve double-precision addition/subtraction. • To add or subtract 32-bit numbers – Add or subtract lower 16 bits – Add or subtract higher 16 bits with carry or borrow • Example:
  • 6. Multiplication • Unsigned multiplication: MUL operand • Signed multiplication: IMUL operand • If operand is a Byte – MUL operand; AX AL * operand • If operand is a Word – MUL operand; DX:AX  AX * operand • Operand can be a general register or memory. Cannot be a constant. • Only CF and OF are affected.
  • 7. Multiplication – Cont. • CF=OF=0 – Unsigned multiplication: if upper half of result is 0. – Signed multiplication: if upper half of result is a sign extension of lower half. • Example: Let AX=FFFFh and BX=0002h – MUL BL; AX01FEh (255 * 2 = 510) CF=OF=1 – IMUL BL; AXFFFEh (-1 * 2 = -2) CF=OF=0 – MUL AL; AXFE01 (255 * 255 = 65025) CF=OF=1 – IMUL AL; AX0001 (-1 * -1 = 1) CF=OF=0 – MUL BX; DX0001 AXFFFE CF=OF=1 – IMUL BX; DXFFFF AXFFFE CF=OF=0
  • 8. Application: Inputting a Decimal Number • Inputting a 2-digit decimal number MOV AH, 1 ;read first digit INT 21H SUB AL, ‘0’ ; convert digit from ASCII code to binary MOV BL, 10 MUL BL ; multiply digit by 10 MOV CL, AL MOV AH, 1 ; read 2nd digit INT 21H SUB AL, ‘0’ ; convert digit from ASCII code to binary ADD AL, CL ; AL contains the 2-digit number
  • 9. Division • Unsigned division: DIV operand • Signed division: IDIV operand • If operand is a Byte – DIV Operand ; AX  AX/operand – AH= Remainder, AL= Quotient • If operand is a Word – DIV Operand ; DX:AX  DX:AX/operand – DX=Remainder, AX= Quotient • Operand can be a general register or memory. Cannot be a constant. • All flags are undefined.
  • 10. Division - Cont. • Divide Overflow – If quotient is too big to fit in specified destination (AL or AX) – Happens if divisor much smaller than dividend – Program terminates and displays “Divide Overflow” • Example: Let DX=0000h, AX=0005h, and BX=FFFEh – DIV BX; AX=0000 DX=0005 – IDIV BX; AX=FFFE DX=0001 • Example: Let DX=FFFFh, AX=FFFBh, and BX=0002h – IDIV BX; AX=FFFE DX=FFFF – DIV BX; DIVIDE Overflow • Example: Let AX=00FBh (251), and BL=FFh – DIV BL; AH=FB AL=00 – IDIV BL; DIVIDE Overflow
  • 11. Application: Outputting a Decimal Number • Outputting a 2-digit decimal number in AX MOV BL, 10 DIV BL ; getting least significant digit ADD AH, ‘0’ ; converting L.S. digit to ASCII MOV DH, AH ; storing L.S. digit temporarily MOV AH, 0 DIV BL ; getting most significant digit ADD AH, ‘0’ ; converting M.S. digit into ASCII MOV DL, AH ; displaying M.S. digit MOV AH, 2 INT 21H MOV DL, DH ; displaying least significant digit INT21H
  • 12. Logic Instructions • The AND, OR, and XOR instructions perform named bit-wise logical operation. • Syntax: – AND destination, source – OR destination, source – XOR destination, source 10101010 AND 11110000 --------------- 10100000 10101010 OR 11110000 --------------- 11111010 10101010 XOR 11110000 --------------- 01011010
  • 13. Logic Instructions - Cont. • AND instruction used to clear specific destinations bits while preserving others. – A 0 mask bit clears corresponding destination bit – A 1 mask bit preserves corresponding destination bit • OR instruction used to set specific destinations bits while preserving others. – A 1 mask bit sets corresponding destination bit – A 0 mask bit preserves corresponding destination bit • XOR instruction used to complement specific destinations bits while preserving others. – A 1 mask bit complements corresponding destination bit – A 0 mask bit preserves corresponding destination bit
  • 14. Logic Instructions - Cont. • Effect on flags – SF, ZF, PF change based on result – AF undefined – CF=OF=0 • Examples: – Converting ASCII digit to a number – SUB AL, 30h – AND AL, 0Fh – Converting a lowercase letter to uppercase – SUB AL, 20h – AND AL, 0DFh – Initializing register with 0 – XOR AL, AL
  • 15. Logic Instructions - Cont. • NOT instruction – performs one’s complement operation on destination – Syntax: NOT destination – has no effect on flags. • TEST instruction – performs an AND operation of destination with source but does not change destination – it affects the flags like the AND instruction – used to examine content of individual bits • Example – To test for even numbers – TEST AL, 1; if ZF=1, number is even
  • 17. Shift Instructions can be classified as: • Logical shift • Arithmetic shift Four (4) types of Shift instructions direction: • Shift logical left (SHL) • Shift logical right (SHR) • Shift arithmetic left (SAL) • Shift arithmetic right (SAR) • Syntax: – Opcode destination, 1 ; for single-bit shift or rotate – Opcode destination, CL ; for shift or rotate of N bits • SHL ( Shift Logical Left ) and SAL ( Shift Arithmetic Left ) are two different mnemonics but perform the same operation.
  • 18. • Execute the following instructions and determine the status of the flags.
  • 19.
  • 20.
  • 21.
  • 22. Multiplication & Division by Shift • Multiplication by left shift – A left shift by 1 bit doubles the destination value, i.e. multiplies it by 2. • Division by right shift – A right shift by 1 bit halves it and rounds down to the nearest integer, i.e. divides it by 2. • Example: Multiply signed content of AL by 17 – MOV AH, AL – MOV CL, 4 – SAL AL, CL ; AL= 16*AL – ADD AL, AH; AL=16*AL + AL = 17 AL
  • 23. QUIZ • Determine the next value of AL after the execution. 1. MOV AL, AAH MOV CL,06H SHL AL,CL 2. MOV AL, 6BH MOV CL, 06H SHR AL,CL Ans: 1. AL = 80H 2. AL = 01H 3. AL =1FH 3. MOV AL,93H MOV CL,03H SHL AL,CL SAR AL,CL SHR AL,CL
  • 24. ROTATE Instruction • The different types of rotate instruction are: – ROL: rotate left – ROR: rotate right – RCL: rotate left with carry – RCR: rotate right with carry
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. QUIZ