SlideShare a Scribd company logo
MCS-51 Arithmetic Operation
Microprocessor
(MCS-51)
Number Comparison table
Decimal Hexadecimal Binary
0 0 0 0 0 0
1 1 0 0 0 1
2 2 0 0 1 0
3 3 0 0 1 1
4 4 0 1 0 0
5 5 0 1 0 1
6 6 0 1 1 0
7 7 0 1 1 1
8 8 1 0 0 0
9 9 1 0 0 1
1 0 A 1 0 1 0
1 1 B 1 0 1 1
1 2 C 1 1 0 0
1 3 D 1 1 0 1
1 4 E 1 1 1 0
1 5 F 1 1 1 1
28 July 2016 Microprocessor 2
MCS-51 is 8-bits word size
Microcontroller
• MCS-51 is 8-bits word size computer
1 1 0 1 0 0 1 1
D 3
Binary
Hexadecimal
8 Bits = 1 Byte
28 July 2016 Microprocessor 3
Arithmetic operation
• Additional
• Subtraction
• Multiplication
• Division
• Increment
• Decrement
• Decimal Adjustment (to BCD)
28 July 2016 Microprocessor 4
Additional Review
• Decimal
1
3 4 +
9 4
1 2 8
1
9 +
9
1 8
• Hexadecimal
0
B 4 +
1 4
C 8
1
F +
F
1 E
1
F F +
0 1
1 0 0
1
F F +
F F
1 F E
28 July 2016 Microprocessor 5
Additional
MSB
One Byte
Answer
MCS-51 Additional Operation
• Law of operation with Assembly
– The First operand MUST be Acc
– Every additional operation, the Result will store in
• Carry flag (as Most Significant bit)
• Acc
– Every Additional will effect to Carry flag
28 July 2016 Microprocessor 6
Additional Instructions
– Instructions
• ADD A, Rn
• ADD A, #X
• ADD A, Rx
• ADD A, @Ri
• ADDC A, Rn
• ADDC A, #X
• ADDC A, Rx
• ADDC A, @Ri
28 July 2016 Microprocessor 7
Sample Additional (Small number)
• A =
+
• R3 =
• ADD A, R3
• C = = Acc
8 C
3 8
C 40
28 July 2016 Microprocessor 8
Sample Additional (Big number)
• A =
+
• R3 =
• ADD A, R3
• C = = Acc
A 7
B 3
5 A1
28 July 2016 Microprocessor 9
Simple Additional Program
• See Handout Chapter 8
• Example 0:
• Program to summation R0 and R1, then
28 July 2016 Microprocessor 10
Sample “16-bits Additional Program”
• “16-bits Additional Program”
– Such as: 1001100110111011+ 99BB+
1101110010111011 DCBB
1 0111011001110110 1 76 76
• Solution:
– Because the word size of MCS-51 is 8-bits, the
diagram able to draw as below.
28 July 2016 Microprocessor 11
Sample “16-bits Additional Program”
9 9 B B
D C 6 4
x x x x
R1 R2
28 July 2016 Microprocessor 12
P2 P1
x x
ORG 00H
MOV A, R2
ADD A, P1 ; C, Acc
MOV 12h, A
MOV A, R1
ADDC A, P2 ; C, Acc
MOV 11h, Acc
CLR A
MOV Acc.0, C
MOV 10h, Acc
END
10h 11h 12h
01 76 1F
MCS-51 Subtraction Operation
• Law of operation
– Every Subtraction will include Carry flag
– Result will store in Acc
– Result on Carry flag
• “0” on Carry flag represent Positive result in Acc
• “1” on Carry flag represent Negative result in Acc
– Negative number result will be show in a Second
complement format
– Every Subtraction will effect to Carry flag
28 July 2016 Microprocessor 13
Subtraction Review
• Decimal
3 4 -
1 2
2 2
5 +
9
- 4
• Hexadecimal
B 4 -
1 4
C 8
1 C -
1 E
F E
28 July 2016 Microprocessor 14
Borrow (C) = 1
FE = 2 Complement of -2
Mathematic on Binary System
• Normal
5 -
7
-2
+ 4
2
• Binary System
0 5 -
0 7
F E
+ 0 4
0 2
28 July 2016 Microprocessor 15
FE = 2’n Complement of -2
Borrow (C) = 1
Subtraction Instruction
– Instructions
• SUBB A, Rn
• SUBB A, #X
• SUBB A, Rx
• SUBB A, @Ri
• Note: Every Additional will effect to Carry flag
28 July 2016 Microprocessor 16
32 bits Subtraction Program
• _
28 July 2016 Microprocessor 17
9 9 7 A
1 C 9 4
x x x x
11h 12h
21h 22h
9 D B B
D 3 6 4
13h 14h
x x x x
23h 24h
R1 R2 R3 R4
ORG 00H
CLR C
MOV A, R4
SUBB A, 14h
MOV 24h, A
MOV A, R3
SUBB A, 13h
MOV 23h, Acc
MOV A, R2
SUBB A, 12h
MOV 22h, Acc
MOV A, R1
SUBB A, 11h
MOV 21h, Acc
END
Test in Assembly Editor and Emulator
28 July 2016 Microprocessor 18
Assignment 1
• Chapter 8, Example 2
– Complete the Example 2 then check your code in the
Laboratory
– Check and Sign by Instructor
28 July 2016 Microprocessor 19
Homework 2
• Chapter 8,
– Refer to Example 3
– Write diagram and assembly code for MCS-51 to process
“32bits additional program”
– Specify data enter location by yourself.
– Generate Test data by your self (if needed)
– Submit before next class start.
28 July 2016 Microprocessor 21
Multiplication Operation
• Only operate by Register Acc and B
• Answer
– Low Byte store in Acc
– High Byte store in B
• Instruction
– MUL AB
28 July 2016 Microprocessor 22
3 E
9 2
x xy y
x
Sample Multiplication Operation
Basic Multiplication
See Handout Chapter 8
Example 1
28 July 2016 Microprocessor 23
3 E
9 2
x xy y
x
Sample Multiplication Operation
16-bits multiplication:
See Handout Chapter 8
Example 4
28 July 2016 Microprocessor 24
3 E
9 2 x
9 29 2
9 29 2
9 29 2
9 29 2
9 29 2 9 29 2
Division Operation
• Operate by register Acc and B
– Acc / B
• Answer
– Answer store in Acc
– Fraction store in B
• Instruction
– DIV AB
28 July 2016 Microprocessor 25
3 E0 5
Assignment 2
• Perform write program for MCS51 to operate
“16-bits Multiplication”
• Check by Instructor
28 July 2016 Microprocessor 26
Sample Division Operation
28 July 2016 Microprocessor 27
3 E0 5
0 C
3 C
0 2
C 2
5
Increment
• Increase by One
• On Over flow (Increase FF) will return to 00
• Effect to Carry flag?
28 July 2016 Microprocessor 28
Decrement
• Decrease by One
• On Over flow (Decrease 00) will return to FF
• Effect to Carry flag?
28 July 2016 Microprocessor 29
Binary Coded Decimal (BCD)
• Decimal Adjustment Acc
– DA A
28 July 2016 Microprocessor 30
Homework 3
28 July 2016 Microprocessor 31

More Related Content

What's hot

Boothmultiplication
BoothmultiplicationBoothmultiplication
Boothmultiplication
melisha monteiro
 
Digital and logic designs presentation
Digital and logic designs presentationDigital and logic designs presentation
Digital and logic designs presentationHaya Butt
 
Computer arithmetics coa project pdf version
Computer arithmetics coa project pdf versionComputer arithmetics coa project pdf version
Computer arithmetics coa project pdf version
SuryaKumarSahani
 
Scilab: Computing Tool For Engineers
Scilab: Computing Tool For EngineersScilab: Computing Tool For Engineers
Scilab: Computing Tool For Engineers
Naren P.R.
 
Computer architecture
Computer architectureComputer architecture
Computer architectureSanjeev Patel
 
Arithmetic micro operations
Arithmetic micro operationsArithmetic micro operations
Arithmetic micro operations
lavanya marichamy
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operations
VATSAL TRIVEDI
 
CArcMOOC 03.05 - RTL design
CArcMOOC 03.05 - RTL designCArcMOOC 03.05 - RTL design
CArcMOOC 03.05 - RTL design
Alessandro Bogliolo
 
Analysis of algo
Analysis of algoAnalysis of algo
Analysis of algo
Sandeep Bhargava
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operations
Lakshya Sharma
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
Kamal Acharya
 
Binary parallel adder
Binary parallel adderBinary parallel adder
Binary parallel adder
anu surya
 
Register transfer and microoperations
Register transfer and microoperationsRegister transfer and microoperations
Register transfer and microoperations
mahesh kumar prajapat
 
overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...
Rai University
 
Csa stack
Csa stackCsa stack
Csa stack
PCTE
 
Seminar on Digital Multiplier(Booth Multiplier) Using VHDL
Seminar on Digital Multiplier(Booth Multiplier) Using VHDLSeminar on Digital Multiplier(Booth Multiplier) Using VHDL
Seminar on Digital Multiplier(Booth Multiplier) Using VHDL
Naseer LoneRider
 

What's hot (18)

Boothmultiplication
BoothmultiplicationBoothmultiplication
Boothmultiplication
 
4 bit add sub
4 bit add sub4 bit add sub
4 bit add sub
 
Digital and logic designs presentation
Digital and logic designs presentationDigital and logic designs presentation
Digital and logic designs presentation
 
Computer arithmetics coa project pdf version
Computer arithmetics coa project pdf versionComputer arithmetics coa project pdf version
Computer arithmetics coa project pdf version
 
Scilab: Computing Tool For Engineers
Scilab: Computing Tool For EngineersScilab: Computing Tool For Engineers
Scilab: Computing Tool For Engineers
 
Computer architecture
Computer architectureComputer architecture
Computer architecture
 
Arithmetic micro operations
Arithmetic micro operationsArithmetic micro operations
Arithmetic micro operations
 
Logical micro-operations
Logical micro-operationsLogical micro-operations
Logical micro-operations
 
CArcMOOC 03.05 - RTL design
CArcMOOC 03.05 - RTL designCArcMOOC 03.05 - RTL design
CArcMOOC 03.05 - RTL design
 
Binary parallel adder
Binary parallel adderBinary parallel adder
Binary parallel adder
 
Analysis of algo
Analysis of algoAnalysis of algo
Analysis of algo
 
Register transfer language & its micro operations
Register transfer language & its micro operationsRegister transfer language & its micro operations
Register transfer language & its micro operations
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
 
Binary parallel adder
Binary parallel adderBinary parallel adder
Binary parallel adder
 
Register transfer and microoperations
Register transfer and microoperationsRegister transfer and microoperations
Register transfer and microoperations
 
overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...overview of register transfer, micro operations and basic computer organizati...
overview of register transfer, micro operations and basic computer organizati...
 
Csa stack
Csa stackCsa stack
Csa stack
 
Seminar on Digital Multiplier(Booth Multiplier) Using VHDL
Seminar on Digital Multiplier(Booth Multiplier) Using VHDLSeminar on Digital Multiplier(Booth Multiplier) Using VHDL
Seminar on Digital Multiplier(Booth Multiplier) Using VHDL
 

Similar to Microprocessor Week 4-5 MCS-51 Arithmetic operation

How To Tweak Angular 2 Performance
How To Tweak Angular 2 PerformanceHow To Tweak Angular 2 Performance
How To Tweak Angular 2 Performance
Oleksandr Tryshchenko
 
arithmaticpipline-170310085040.pptx
arithmaticpipline-170310085040.pptxarithmaticpipline-170310085040.pptx
arithmaticpipline-170310085040.pptx
AshokRachapalli1
 
Mba om 14_statistical_qualitycontrolmethods
Mba om 14_statistical_qualitycontrolmethodsMba om 14_statistical_qualitycontrolmethods
Mba om 14_statistical_qualitycontrolmethods
Niranjana K.R.
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4
Dr.YNM
 
Computing Just What You Need: Online Data Analysis and Reduction at Extreme ...
Computing Just What You Need: Online Data Analysis and Reduction  at Extreme ...Computing Just What You Need: Online Data Analysis and Reduction  at Extreme ...
Computing Just What You Need: Online Data Analysis and Reduction at Extreme ...
Ian Foster
 
Tutorial-on-DNN-07-Co-design-Precision.pdf
Tutorial-on-DNN-07-Co-design-Precision.pdfTutorial-on-DNN-07-Co-design-Precision.pdf
Tutorial-on-DNN-07-Co-design-Precision.pdf
Duy-Hieu Bui
 
8085 instruction set and Programming
8085 instruction set and Programming 8085 instruction set and Programming
8085 instruction set and Programming
pooja saini
 
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Databricks
 
defense_slides_pengdu
defense_slides_pengdudefense_slides_pengdu
defense_slides_pengduPeng Du
 
streamingalgo88585858585858585pppppp.pptx
streamingalgo88585858585858585pppppp.pptxstreamingalgo88585858585858585pppppp.pptx
streamingalgo88585858585858585pppppp.pptx
GopiNathVelivela
 
Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2 Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2
Databricks
 
High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...
High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...
High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...
IRJET Journal
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
Arunav Ray
 
Design and Implementation of an Efficient 64 bit MAC
Design and Implementation of an Efficient 64 bit MACDesign and Implementation of an Efficient 64 bit MAC
Design and Implementation of an Efficient 64 bit MAC
IJERA Editor
 
Precomputing recommendations with Apache Beam
Precomputing recommendations with Apache BeamPrecomputing recommendations with Apache Beam
Precomputing recommendations with Apache Beam
Tatiana Al-Chueyr
 
5. Arithmaticn combinational Ckt.ppt
5. Arithmaticn combinational Ckt.ppt5. Arithmaticn combinational Ckt.ppt
5. Arithmaticn combinational Ckt.ppt
abhishekchakraborty788933
 
VLSI subsystem design processes and illustration
VLSI subsystem design processes and illustrationVLSI subsystem design processes and illustration
VLSI subsystem design processes and illustration
Vishal kakade
 
Mca i-u-1.1 digital logic circuits, digital component floting and fixed point
Mca i-u-1.1 digital logic circuits, digital component floting and fixed pointMca i-u-1.1 digital logic circuits, digital component floting and fixed point
Mca i-u-1.1 digital logic circuits, digital component floting and fixed point
Rai University
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed point
Rai University
 

Similar to Microprocessor Week 4-5 MCS-51 Arithmetic operation (20)

How To Tweak Angular 2 Performance
How To Tweak Angular 2 PerformanceHow To Tweak Angular 2 Performance
How To Tweak Angular 2 Performance
 
arithmaticpipline-170310085040.pptx
arithmaticpipline-170310085040.pptxarithmaticpipline-170310085040.pptx
arithmaticpipline-170310085040.pptx
 
Mba om 14_statistical_qualitycontrolmethods
Mba om 14_statistical_qualitycontrolmethodsMba om 14_statistical_qualitycontrolmethods
Mba om 14_statistical_qualitycontrolmethods
 
adders(1)
adders(1)adders(1)
adders(1)
 
Data flow model -Lecture-4
Data flow model -Lecture-4Data flow model -Lecture-4
Data flow model -Lecture-4
 
Computing Just What You Need: Online Data Analysis and Reduction at Extreme ...
Computing Just What You Need: Online Data Analysis and Reduction  at Extreme ...Computing Just What You Need: Online Data Analysis and Reduction  at Extreme ...
Computing Just What You Need: Online Data Analysis and Reduction at Extreme ...
 
Tutorial-on-DNN-07-Co-design-Precision.pdf
Tutorial-on-DNN-07-Co-design-Precision.pdfTutorial-on-DNN-07-Co-design-Precision.pdf
Tutorial-on-DNN-07-Co-design-Precision.pdf
 
8085 instruction set and Programming
8085 instruction set and Programming 8085 instruction set and Programming
8085 instruction set and Programming
 
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
Cost-Based Optimizer in Apache Spark 2.2 Ron Hu, Sameer Agarwal, Wenchen Fan ...
 
defense_slides_pengdu
defense_slides_pengdudefense_slides_pengdu
defense_slides_pengdu
 
streamingalgo88585858585858585pppppp.pptx
streamingalgo88585858585858585pppppp.pptxstreamingalgo88585858585858585pppppp.pptx
streamingalgo88585858585858585pppppp.pptx
 
Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2 Cost-Based Optimizer in Apache Spark 2.2
Cost-Based Optimizer in Apache Spark 2.2
 
High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...
High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...
High-Speed and Energy-Efficient MAC Design using Vedic Multiplier and Carry S...
 
Isc computer project final upload last
Isc computer project final upload lastIsc computer project final upload last
Isc computer project final upload last
 
Design and Implementation of an Efficient 64 bit MAC
Design and Implementation of an Efficient 64 bit MACDesign and Implementation of an Efficient 64 bit MAC
Design and Implementation of an Efficient 64 bit MAC
 
Precomputing recommendations with Apache Beam
Precomputing recommendations with Apache BeamPrecomputing recommendations with Apache Beam
Precomputing recommendations with Apache Beam
 
5. Arithmaticn combinational Ckt.ppt
5. Arithmaticn combinational Ckt.ppt5. Arithmaticn combinational Ckt.ppt
5. Arithmaticn combinational Ckt.ppt
 
VLSI subsystem design processes and illustration
VLSI subsystem design processes and illustrationVLSI subsystem design processes and illustration
VLSI subsystem design processes and illustration
 
Mca i-u-1.1 digital logic circuits, digital component floting and fixed point
Mca i-u-1.1 digital logic circuits, digital component floting and fixed pointMca i-u-1.1 digital logic circuits, digital component floting and fixed point
Mca i-u-1.1 digital logic circuits, digital component floting and fixed point
 
digital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed pointdigital logic circuits, digital component floting and fixed point
digital logic circuits, digital component floting and fixed point
 

More from Arkhom Jodtang

MCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016AMCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016A
Arkhom Jodtang
 
Microprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsMicroprocessor Week 10: Applications
Microprocessor Week 10: Applications
Arkhom Jodtang
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and Counter
Arkhom Jodtang
 
Microprocessor Week 8: Advance programming
Microprocessor Week 8: Advance programmingMicroprocessor Week 8: Advance programming
Microprocessor Week 8: Advance programming
Arkhom Jodtang
 
Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine
Arkhom Jodtang
 
Microprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and OperationMicroprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and Operation
Arkhom Jodtang
 
Microprocessor Week1: Introduction
Microprocessor Week1: IntroductionMicroprocessor Week1: Introduction
Microprocessor Week1: Introduction
Arkhom Jodtang
 
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Arkhom Jodtang
 
Use of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS WordUse of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS Word
Arkhom Jodtang
 
Microprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructionsMicroprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructions
Arkhom Jodtang
 
Microprocessor: Delay technique
Microprocessor: Delay techniqueMicroprocessor: Delay technique
Microprocessor: Delay technique
Arkhom Jodtang
 
Distance Measuring Car
Distance Measuring CarDistance Measuring Car
Distance Measuring Car
Arkhom Jodtang
 
Microprocessor Week 7: Branch Instruction
Microprocessor Week 7: Branch InstructionMicroprocessor Week 7: Branch Instruction
Microprocessor Week 7: Branch Instruction
Arkhom Jodtang
 
Tamech 2013 Presentation
Tamech 2013 PresentationTamech 2013 Presentation
Tamech 2013 Presentation
Arkhom Jodtang
 
Electronics & Avionics project
Electronics & Avionics projectElectronics & Avionics project
Electronics & Avionics project
Arkhom Jodtang
 

More from Arkhom Jodtang (15)

MCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016AMCS51 Training board Model CATC2016A
MCS51 Training board Model CATC2016A
 
Microprocessor Week 10: Applications
Microprocessor Week 10: ApplicationsMicroprocessor Week 10: Applications
Microprocessor Week 10: Applications
 
Microprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and CounterMicroprocessor Week 9: Timer and Counter
Microprocessor Week 9: Timer and Counter
 
Microprocessor Week 8: Advance programming
Microprocessor Week 8: Advance programmingMicroprocessor Week 8: Advance programming
Microprocessor Week 8: Advance programming
 
Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine Microprocessor Week 8: Subroutine
Microprocessor Week 8: Subroutine
 
Microprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and OperationMicroprocessor Week 2: CH2 Circuit and Operation
Microprocessor Week 2: CH2 Circuit and Operation
 
Microprocessor Week1: Introduction
Microprocessor Week1: IntroductionMicroprocessor Week1: Introduction
Microprocessor Week1: Introduction
 
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
Microprocessor laboratory 03 Arithmetic Operation (Additional and Subtraction)
 
Use of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS WordUse of Computer & IT, Laboratory MS Word
Use of Computer & IT, Laboratory MS Word
 
Microprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructionsMicroprocessor Laboratory 2: Logical instructions
Microprocessor Laboratory 2: Logical instructions
 
Microprocessor: Delay technique
Microprocessor: Delay techniqueMicroprocessor: Delay technique
Microprocessor: Delay technique
 
Distance Measuring Car
Distance Measuring CarDistance Measuring Car
Distance Measuring Car
 
Microprocessor Week 7: Branch Instruction
Microprocessor Week 7: Branch InstructionMicroprocessor Week 7: Branch Instruction
Microprocessor Week 7: Branch Instruction
 
Tamech 2013 Presentation
Tamech 2013 PresentationTamech 2013 Presentation
Tamech 2013 Presentation
 
Electronics & Avionics project
Electronics & Avionics projectElectronics & Avionics project
Electronics & Avionics project
 

Recently uploaded

14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
nooriasukmaningtyas
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
nooriasukmaningtyas
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
anoopmanoharan2
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
obonagu
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
benykoy2024
 

Recently uploaded (20)

14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...A review on techniques and modelling methodologies used for checking electrom...
A review on techniques and modelling methodologies used for checking electrom...
 
Low power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniquesLow power architecture of logic gates using adiabatic techniques
Low power architecture of logic gates using adiabatic techniques
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
PPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testingPPT on GRP pipes manufacturing and testing
PPT on GRP pipes manufacturing and testing
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
 

Microprocessor Week 4-5 MCS-51 Arithmetic operation

  • 2. Number Comparison table Decimal Hexadecimal Binary 0 0 0 0 0 0 1 1 0 0 0 1 2 2 0 0 1 0 3 3 0 0 1 1 4 4 0 1 0 0 5 5 0 1 0 1 6 6 0 1 1 0 7 7 0 1 1 1 8 8 1 0 0 0 9 9 1 0 0 1 1 0 A 1 0 1 0 1 1 B 1 0 1 1 1 2 C 1 1 0 0 1 3 D 1 1 0 1 1 4 E 1 1 1 0 1 5 F 1 1 1 1 28 July 2016 Microprocessor 2
  • 3. MCS-51 is 8-bits word size Microcontroller • MCS-51 is 8-bits word size computer 1 1 0 1 0 0 1 1 D 3 Binary Hexadecimal 8 Bits = 1 Byte 28 July 2016 Microprocessor 3
  • 4. Arithmetic operation • Additional • Subtraction • Multiplication • Division • Increment • Decrement • Decimal Adjustment (to BCD) 28 July 2016 Microprocessor 4
  • 5. Additional Review • Decimal 1 3 4 + 9 4 1 2 8 1 9 + 9 1 8 • Hexadecimal 0 B 4 + 1 4 C 8 1 F + F 1 E 1 F F + 0 1 1 0 0 1 F F + F F 1 F E 28 July 2016 Microprocessor 5 Additional MSB One Byte Answer
  • 6. MCS-51 Additional Operation • Law of operation with Assembly – The First operand MUST be Acc – Every additional operation, the Result will store in • Carry flag (as Most Significant bit) • Acc – Every Additional will effect to Carry flag 28 July 2016 Microprocessor 6
  • 7. Additional Instructions – Instructions • ADD A, Rn • ADD A, #X • ADD A, Rx • ADD A, @Ri • ADDC A, Rn • ADDC A, #X • ADDC A, Rx • ADDC A, @Ri 28 July 2016 Microprocessor 7
  • 8. Sample Additional (Small number) • A = + • R3 = • ADD A, R3 • C = = Acc 8 C 3 8 C 40 28 July 2016 Microprocessor 8
  • 9. Sample Additional (Big number) • A = + • R3 = • ADD A, R3 • C = = Acc A 7 B 3 5 A1 28 July 2016 Microprocessor 9
  • 10. Simple Additional Program • See Handout Chapter 8 • Example 0: • Program to summation R0 and R1, then 28 July 2016 Microprocessor 10
  • 11. Sample “16-bits Additional Program” • “16-bits Additional Program” – Such as: 1001100110111011+ 99BB+ 1101110010111011 DCBB 1 0111011001110110 1 76 76 • Solution: – Because the word size of MCS-51 is 8-bits, the diagram able to draw as below. 28 July 2016 Microprocessor 11
  • 12. Sample “16-bits Additional Program” 9 9 B B D C 6 4 x x x x R1 R2 28 July 2016 Microprocessor 12 P2 P1 x x ORG 00H MOV A, R2 ADD A, P1 ; C, Acc MOV 12h, A MOV A, R1 ADDC A, P2 ; C, Acc MOV 11h, Acc CLR A MOV Acc.0, C MOV 10h, Acc END 10h 11h 12h 01 76 1F
  • 13. MCS-51 Subtraction Operation • Law of operation – Every Subtraction will include Carry flag – Result will store in Acc – Result on Carry flag • “0” on Carry flag represent Positive result in Acc • “1” on Carry flag represent Negative result in Acc – Negative number result will be show in a Second complement format – Every Subtraction will effect to Carry flag 28 July 2016 Microprocessor 13
  • 14. Subtraction Review • Decimal 3 4 - 1 2 2 2 5 + 9 - 4 • Hexadecimal B 4 - 1 4 C 8 1 C - 1 E F E 28 July 2016 Microprocessor 14 Borrow (C) = 1 FE = 2 Complement of -2
  • 15. Mathematic on Binary System • Normal 5 - 7 -2 + 4 2 • Binary System 0 5 - 0 7 F E + 0 4 0 2 28 July 2016 Microprocessor 15 FE = 2’n Complement of -2 Borrow (C) = 1
  • 16. Subtraction Instruction – Instructions • SUBB A, Rn • SUBB A, #X • SUBB A, Rx • SUBB A, @Ri • Note: Every Additional will effect to Carry flag 28 July 2016 Microprocessor 16
  • 17. 32 bits Subtraction Program • _ 28 July 2016 Microprocessor 17 9 9 7 A 1 C 9 4 x x x x 11h 12h 21h 22h 9 D B B D 3 6 4 13h 14h x x x x 23h 24h R1 R2 R3 R4 ORG 00H CLR C MOV A, R4 SUBB A, 14h MOV 24h, A MOV A, R3 SUBB A, 13h MOV 23h, Acc MOV A, R2 SUBB A, 12h MOV 22h, Acc MOV A, R1 SUBB A, 11h MOV 21h, Acc END
  • 18. Test in Assembly Editor and Emulator 28 July 2016 Microprocessor 18
  • 19. Assignment 1 • Chapter 8, Example 2 – Complete the Example 2 then check your code in the Laboratory – Check and Sign by Instructor 28 July 2016 Microprocessor 19
  • 20.
  • 21. Homework 2 • Chapter 8, – Refer to Example 3 – Write diagram and assembly code for MCS-51 to process “32bits additional program” – Specify data enter location by yourself. – Generate Test data by your self (if needed) – Submit before next class start. 28 July 2016 Microprocessor 21
  • 22. Multiplication Operation • Only operate by Register Acc and B • Answer – Low Byte store in Acc – High Byte store in B • Instruction – MUL AB 28 July 2016 Microprocessor 22 3 E 9 2 x xy y x
  • 23. Sample Multiplication Operation Basic Multiplication See Handout Chapter 8 Example 1 28 July 2016 Microprocessor 23 3 E 9 2 x xy y x
  • 24. Sample Multiplication Operation 16-bits multiplication: See Handout Chapter 8 Example 4 28 July 2016 Microprocessor 24 3 E 9 2 x 9 29 2 9 29 2 9 29 2 9 29 2 9 29 2 9 29 2
  • 25. Division Operation • Operate by register Acc and B – Acc / B • Answer – Answer store in Acc – Fraction store in B • Instruction – DIV AB 28 July 2016 Microprocessor 25 3 E0 5
  • 26. Assignment 2 • Perform write program for MCS51 to operate “16-bits Multiplication” • Check by Instructor 28 July 2016 Microprocessor 26
  • 27. Sample Division Operation 28 July 2016 Microprocessor 27 3 E0 5 0 C 3 C 0 2 C 2 5
  • 28. Increment • Increase by One • On Over flow (Increase FF) will return to 00 • Effect to Carry flag? 28 July 2016 Microprocessor 28
  • 29. Decrement • Decrease by One • On Over flow (Decrease 00) will return to FF • Effect to Carry flag? 28 July 2016 Microprocessor 29
  • 30. Binary Coded Decimal (BCD) • Decimal Adjustment Acc – DA A 28 July 2016 Microprocessor 30
  • 31. Homework 3 28 July 2016 Microprocessor 31