SlideShare a Scribd company logo
Prof. Nitin Ahire 1
Singed number concept
in
8051 Microcontroller
Nitin Ahire
XIE Mahim
Prof. Nitin Ahire 2
Singed number concept
• In everyday life, numbers are used that
could be +Ve or –Ve
• In the 8051 the MSB bit is set aside for the
sign
• If MSB(D7) =1 represent negative number
• If MSB(D7) =0 represent positive numbers
• The remaining bit D0 to D6 used for
magnitude.
Prof. Nitin Ahire 3
As 8051 is a 8 bit controller here
we consider the 8 bit numbers
D7 D6 D1D2D3D4D5 D0
SIGN MAGNITUDE
Prof. Nitin Ahire 4
POSITIVE NUMBERS
• The range of positive numbers can be
represent by the format as shown in figure
• It range from 0 to +127
0 0000 0000
+1 0000 0001
+5 0000 0101
+127 0111 1111
Prof. Nitin Ahire 5
NEGATIVE NUMBERS
• For negative number D7=1 however the
magnitude is represented in it’s 2’s
compliment form
• Steps
1 write the magnitude of the number in 8 bit
binary
2 invert each bit
3 add one to it
Prof. Nitin Ahire 6
• Show how the 8051 would represent – 5
• Sol:
0000 0101 5 in 8-bit binary
1111 1010 invert bit
1111 1011 add 1 ( which is FB h )
Prof. Nitin Ahire 7
• Show how the 8051 would represent -128
• Sol:
1000 0000
0111 1111
1000 0000 ( which become 80h)
Prof. Nitin Ahire 8
Range of singed numbers
• Decimal binary Hex
-128 1000 0000 80
-127 1000 0001 81
-126 1000 0010 82
… ….. …… ….
-2 1111 1110 FE
-1 1111 1111 FF
0 0000 0000 00
+1 0000 0001 01
+2 0000 0010 02
… …… ……. ….
+127 0111 1111 7F
Prof. Nitin Ahire 9
Overflow problem in signed number
• What is an overflow?
• If the result of an operation on the signed
numbers is too large for the register, an
overflow has occurred
CY AC -OVRS0RS1FO P
Prof. Nitin Ahire 10
Example
• Examine the following code and analyze
the result
MOV A,# +96
MOV R1, # +70
ADD A,R1
Prof. Nitin Ahire 11
Solution
+ 96 0110 0000 60h
+ 70 0100 0110 46h
-------- ---------------
+166 1010 0110 A6 and OV =1
according to CPU the result -90h which is wrong.
( OV = 1)
+166 is not the valid signed number. ( 0 to +127)
Prof. Nitin Ahire 12
When is the OV flag set?
1. There is carry from D6 to D7 but no carry
out of D7 (CY=0).
2. There is a carry from D7 out (CY=1) but
no carry from D6 to D7.
Prof. Nitin Ahire 13
Example 1
• MOV A, #-2 (FEh) ( 1111 1110)
• MOV R1,#-5 (FBh) ( 1111 1011)
• ADD A,R1 (F9h=-7, 1111 1001correct),
• So CPU generate OV=0
Prof. Nitin Ahire 14
Example 2
MOV A, #-128 ; (80H)
MOV R4,#-2 (FEH)
ADD A,R4 ( A=7EH =+127 INVALID )
So CPU generate OV =1
Prof. Nitin Ahire 15
Example 3
• MOV A,#+7; A=0000 0111 (A=07H)
• MOV R1,#+18; R1= 0001 0010 (R1=12H)
• ADD A,R1; A=0001 1001 (A=19H=+25)
According to CPU, this is +25, which is
correct (OV=0)
Prof. Nitin Ahire 16
• In any signed number addition OV
indicates whether the result is valid or not
• If OV=1, the result is erroneous
• If OV=0, the result is valid.
Prof. Nitin Ahire 17
BCD ADDITION
• Assume that 5 BCD data items are stored
in RAM location starting at 40H, write a
program to find the sum of all numbers.
The result must be in BCD.
Prof. Nitin Ahire 18
• Data 40=(71)
• 41=(11)
• 42=(65)
• 43=(59)
• 44=(37)
Prof. Nitin Ahire 19
Solution
• MOV R0,#40H
MOV R2,05H
CLR A
MOV R7,A
AGAIN:ADD A,@R0
DA A
JNC NEXT
INC R7
NEXT: INC RO
DJNZ R2,AGAIN
END

More Related Content

What's hot

12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
JatinJatin30
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
pyingkodi maran
 
Counter
CounterCounter
Counter
Naufal Qodari
 
Registers-shift register
Registers-shift registerRegisters-shift register
Registers-shift register
Bilawal Fiaz
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language Programming
Ravikumar Tiwari
 
K - Map
  K - Map    K - Map
K - Map
Abhishek Choksi
 
Kmap..(karnaugh map)
Kmap..(karnaugh map)Kmap..(karnaugh map)
Kmap..(karnaugh map)
Zain Jafri
 
Encoders
EncodersEncoders
Signed numbers in 8051
Signed numbers in 8051Signed numbers in 8051
Signed numbers in 8051
Zeeshan Ahmed
 
Counters
CountersCounters
Counters
Abhilash Nair
 
Counters
CountersCounters
Counters
Ravi Maurya
 
Keyboard Interfacing .pptx
Keyboard Interfacing .pptxKeyboard Interfacing .pptx
Keyboard Interfacing .pptx
livaunnoor
 
Decoder
DecoderDecoder
Multiplexer & Demultiplexer
Multiplexer & DemultiplexerMultiplexer & Demultiplexer
Multiplexer & Demultiplexer
Jatin Sharma
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
Laguna State Polytechnic University
 
8085 Interfacing with I/O Devices or Memory
8085 Interfacing with I/O Devices or Memory8085 Interfacing with I/O Devices or Memory
8085 Interfacing with I/O Devices or Memory
Saumay Paul
 
Clock divide by 3
Clock divide by 3Clock divide by 3
Clock divide by 3
Ashok Reddy
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solutionZunAib Ali
 
Dlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} pptDlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} ppt
Tanish Gupta
 

What's hot (20)

12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...12.Representation of signed binary numbers.  Binary codes - BCD code, Gray co...
12.Representation of signed binary numbers. Binary codes - BCD code, Gray co...
 
Signed Binary Numbers
Signed Binary NumbersSigned Binary Numbers
Signed Binary Numbers
 
Counter
CounterCounter
Counter
 
Chapter 5 counter
Chapter 5 counterChapter 5 counter
Chapter 5 counter
 
Registers-shift register
Registers-shift registerRegisters-shift register
Registers-shift register
 
8051 Assembly Language Programming
8051 Assembly Language Programming8051 Assembly Language Programming
8051 Assembly Language Programming
 
K - Map
  K - Map    K - Map
K - Map
 
Kmap..(karnaugh map)
Kmap..(karnaugh map)Kmap..(karnaugh map)
Kmap..(karnaugh map)
 
Encoders
EncodersEncoders
Encoders
 
Signed numbers in 8051
Signed numbers in 8051Signed numbers in 8051
Signed numbers in 8051
 
Counters
CountersCounters
Counters
 
Counters
CountersCounters
Counters
 
Keyboard Interfacing .pptx
Keyboard Interfacing .pptxKeyboard Interfacing .pptx
Keyboard Interfacing .pptx
 
Decoder
DecoderDecoder
Decoder
 
Multiplexer & Demultiplexer
Multiplexer & DemultiplexerMultiplexer & Demultiplexer
Multiplexer & Demultiplexer
 
Number Systems Basic Concepts
Number Systems Basic ConceptsNumber Systems Basic Concepts
Number Systems Basic Concepts
 
8085 Interfacing with I/O Devices or Memory
8085 Interfacing with I/O Devices or Memory8085 Interfacing with I/O Devices or Memory
8085 Interfacing with I/O Devices or Memory
 
Clock divide by 3
Clock divide by 3Clock divide by 3
Clock divide by 3
 
8051-mazidi-solution
8051-mazidi-solution8051-mazidi-solution
8051-mazidi-solution
 
Dlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} pptDlc{binary to gray code conversion} ppt
Dlc{binary to gray code conversion} ppt
 

Similar to 8051 singed number concept [compatibility mode]

Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:
Asif Iqbal
 
Alu1
Alu1Alu1
Representation Of Numbers and Characters
Representation Of Numbers and CharactersRepresentation Of Numbers and Characters
Representation Of Numbers and Characters
Shaikh Kamrul Islam (Konok kamrul)
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
Meenakshi Paul
 
Parallel adders
Parallel addersParallel adders
Parallel adders
sana younas
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
Ravi Kumar
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
Ravi Kumar
 
L3 ARITHMETIC OPERATIONS.pptx
L3 ARITHMETIC OPERATIONS.pptxL3 ARITHMETIC OPERATIONS.pptx
L3 ARITHMETIC OPERATIONS.pptx
Harish257692
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
skatiarrahaman
 
CA UNIT II.pptx
CA UNIT II.pptxCA UNIT II.pptx
CA UNIT II.pptx
ssuser9dbd7e
 
Counit2
Counit2Counit2
Counit2
Himanshu Dua
 
ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS	  ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS
Amirthavalli Senthil
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
amudhak10
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
amudhak10
 
number system.ppt
number system.pptnumber system.ppt
number system.ppt
ShrutiSharma485933
 
CA Unit ii
CA Unit iiCA Unit ii
CA Unit ii
AmirthavalliR
 
tCh10.ppt
tCh10.ppttCh10.ppt
Data representation notes class 11
Data representation notes class 11Data representation notes class 11
Data representation notes class 11
ShresthMaurya1
 
3810-08.ppt
3810-08.ppt3810-08.ppt
3810-08.ppt
SrinivasanCSE
 

Similar to 8051 singed number concept [compatibility mode] (20)

Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:Unit-1 Digital Design and Binary Numbers:
Unit-1 Digital Design and Binary Numbers:
 
Alu1
Alu1Alu1
Alu1
 
Representation Of Numbers and Characters
Representation Of Numbers and CharactersRepresentation Of Numbers and Characters
Representation Of Numbers and Characters
 
Binary Arithmetic
Binary ArithmeticBinary Arithmetic
Binary Arithmetic
 
Parallel adders
Parallel addersParallel adders
Parallel adders
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
Computer Architecture
Computer ArchitectureComputer Architecture
Computer Architecture
 
L3 ARITHMETIC OPERATIONS.pptx
L3 ARITHMETIC OPERATIONS.pptxL3 ARITHMETIC OPERATIONS.pptx
L3 ARITHMETIC OPERATIONS.pptx
 
Hemanth143
Hemanth143 Hemanth143
Hemanth143
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
CA UNIT II.pptx
CA UNIT II.pptxCA UNIT II.pptx
CA UNIT II.pptx
 
Counit2
Counit2Counit2
Counit2
 
ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS	  ARITHMETIC FOR COMPUTERS
ARITHMETIC FOR COMPUTERS
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
number system.ppt
number system.pptnumber system.ppt
number system.ppt
 
CA Unit ii
CA Unit iiCA Unit ii
CA Unit ii
 
tCh10.ppt
tCh10.ppttCh10.ppt
tCh10.ppt
 
Data representation notes class 11
Data representation notes class 11Data representation notes class 11
Data representation notes class 11
 
3810-08.ppt
3810-08.ppt3810-08.ppt
3810-08.ppt
 

More from Nitin Ahire

Microprocessor 8086 8087_nitin ahire
Microprocessor 8086 8087_nitin ahireMicroprocessor 8086 8087_nitin ahire
Microprocessor 8086 8087_nitin ahire
Nitin Ahire
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
Nitin Ahire
 
8085 ppi 8255 and 8155
8085 ppi 8255 and 81558085 ppi 8255 and 8155
8085 ppi 8255 and 8155
Nitin Ahire
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
Nitin Ahire
 
Addressing mode of 8051
Addressing mode of 8051Addressing mode of 8051
Addressing mode of 8051
Nitin Ahire
 
8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set
Nitin Ahire
 
8051 (microcontroller)class1
8051 (microcontroller)class18051 (microcontroller)class1
8051 (microcontroller)class1
Nitin Ahire
 
Serial communication in 8085
Serial communication in 8085Serial communication in 8085
Serial communication in 8085
Nitin Ahire
 
Interfacing of io device to 8085
Interfacing of io device to 8085Interfacing of io device to 8085
Interfacing of io device to 8085
Nitin Ahire
 
Interrupt of 8085
Interrupt of 8085Interrupt of 8085
Interrupt of 8085
Nitin Ahire
 

More from Nitin Ahire (10)

Microprocessor 8086 8087_nitin ahire
Microprocessor 8086 8087_nitin ahireMicroprocessor 8086 8087_nitin ahire
Microprocessor 8086 8087_nitin ahire
 
8051 Microcontroller
8051 Microcontroller8051 Microcontroller
8051 Microcontroller
 
8085 ppi 8255 and 8155
8085 ppi 8255 and 81558085 ppi 8255 and 8155
8085 ppi 8255 and 8155
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Addressing mode of 8051
Addressing mode of 8051Addressing mode of 8051
Addressing mode of 8051
 
8051 micro controllers Instruction set
8051 micro controllers Instruction set 8051 micro controllers Instruction set
8051 micro controllers Instruction set
 
8051 (microcontroller)class1
8051 (microcontroller)class18051 (microcontroller)class1
8051 (microcontroller)class1
 
Serial communication in 8085
Serial communication in 8085Serial communication in 8085
Serial communication in 8085
 
Interfacing of io device to 8085
Interfacing of io device to 8085Interfacing of io device to 8085
Interfacing of io device to 8085
 
Interrupt of 8085
Interrupt of 8085Interrupt of 8085
Interrupt of 8085
 

Recently uploaded

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 

Recently uploaded (20)

FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 

8051 singed number concept [compatibility mode]

  • 1. Prof. Nitin Ahire 1 Singed number concept in 8051 Microcontroller Nitin Ahire XIE Mahim
  • 2. Prof. Nitin Ahire 2 Singed number concept • In everyday life, numbers are used that could be +Ve or –Ve • In the 8051 the MSB bit is set aside for the sign • If MSB(D7) =1 represent negative number • If MSB(D7) =0 represent positive numbers • The remaining bit D0 to D6 used for magnitude.
  • 3. Prof. Nitin Ahire 3 As 8051 is a 8 bit controller here we consider the 8 bit numbers D7 D6 D1D2D3D4D5 D0 SIGN MAGNITUDE
  • 4. Prof. Nitin Ahire 4 POSITIVE NUMBERS • The range of positive numbers can be represent by the format as shown in figure • It range from 0 to +127 0 0000 0000 +1 0000 0001 +5 0000 0101 +127 0111 1111
  • 5. Prof. Nitin Ahire 5 NEGATIVE NUMBERS • For negative number D7=1 however the magnitude is represented in it’s 2’s compliment form • Steps 1 write the magnitude of the number in 8 bit binary 2 invert each bit 3 add one to it
  • 6. Prof. Nitin Ahire 6 • Show how the 8051 would represent – 5 • Sol: 0000 0101 5 in 8-bit binary 1111 1010 invert bit 1111 1011 add 1 ( which is FB h )
  • 7. Prof. Nitin Ahire 7 • Show how the 8051 would represent -128 • Sol: 1000 0000 0111 1111 1000 0000 ( which become 80h)
  • 8. Prof. Nitin Ahire 8 Range of singed numbers • Decimal binary Hex -128 1000 0000 80 -127 1000 0001 81 -126 1000 0010 82 … ….. …… …. -2 1111 1110 FE -1 1111 1111 FF 0 0000 0000 00 +1 0000 0001 01 +2 0000 0010 02 … …… ……. …. +127 0111 1111 7F
  • 9. Prof. Nitin Ahire 9 Overflow problem in signed number • What is an overflow? • If the result of an operation on the signed numbers is too large for the register, an overflow has occurred CY AC -OVRS0RS1FO P
  • 10. Prof. Nitin Ahire 10 Example • Examine the following code and analyze the result MOV A,# +96 MOV R1, # +70 ADD A,R1
  • 11. Prof. Nitin Ahire 11 Solution + 96 0110 0000 60h + 70 0100 0110 46h -------- --------------- +166 1010 0110 A6 and OV =1 according to CPU the result -90h which is wrong. ( OV = 1) +166 is not the valid signed number. ( 0 to +127)
  • 12. Prof. Nitin Ahire 12 When is the OV flag set? 1. There is carry from D6 to D7 but no carry out of D7 (CY=0). 2. There is a carry from D7 out (CY=1) but no carry from D6 to D7.
  • 13. Prof. Nitin Ahire 13 Example 1 • MOV A, #-2 (FEh) ( 1111 1110) • MOV R1,#-5 (FBh) ( 1111 1011) • ADD A,R1 (F9h=-7, 1111 1001correct), • So CPU generate OV=0
  • 14. Prof. Nitin Ahire 14 Example 2 MOV A, #-128 ; (80H) MOV R4,#-2 (FEH) ADD A,R4 ( A=7EH =+127 INVALID ) So CPU generate OV =1
  • 15. Prof. Nitin Ahire 15 Example 3 • MOV A,#+7; A=0000 0111 (A=07H) • MOV R1,#+18; R1= 0001 0010 (R1=12H) • ADD A,R1; A=0001 1001 (A=19H=+25) According to CPU, this is +25, which is correct (OV=0)
  • 16. Prof. Nitin Ahire 16 • In any signed number addition OV indicates whether the result is valid or not • If OV=1, the result is erroneous • If OV=0, the result is valid.
  • 17. Prof. Nitin Ahire 17 BCD ADDITION • Assume that 5 BCD data items are stored in RAM location starting at 40H, write a program to find the sum of all numbers. The result must be in BCD.
  • 18. Prof. Nitin Ahire 18 • Data 40=(71) • 41=(11) • 42=(65) • 43=(59) • 44=(37)
  • 19. Prof. Nitin Ahire 19 Solution • MOV R0,#40H MOV R2,05H CLR A MOV R7,A AGAIN:ADD A,@R0 DA A JNC NEXT INC R7 NEXT: INC RO DJNZ R2,AGAIN END