SlideShare una empresa de Scribd logo
1 de 16
SARVAJANIK COLLEGE OF ENGINEERING AND
TECHNOLOGY
COMPUTER ENGINEERING DEPARTMENT
B. E.-II, CO-E, SEM-IV
(EVEN-2019)
ALA Presentation
on
“Signed Addition And Subtraction”
Subject Name : Computer Organisation(2140702)
Prepared and Presented by (Group No. : 14 )
Pathik Thakor (170420107557)
Jasmin Thummar (170420107558)
Uttam Thummar (170420107559)
Keyur Vadodariya (170420107561)
1
Overview
• Representation of Number
• Addition & Subtraction Algorithm
• Flow Chart
• Examples
• Hardware implementation
2
SIGNED BIT REPRESENTATION
Example: Represent +9 and -9 in 7 bit-binary number
Only one way to represent + 9 ==> 0 001001
Three different ways to represent - 9:
In signed-magnitude: 1 001001
In signed-1's complement: 1 110110
In signed-2's complement: 1 110111
Representation of both positive and negative numbers
- Following 3 representations
Signed magnitude representation
Signed 1's complement representation
Signed 2's complement representation
3
Sign-magnitude number
 A sign-magnitude
number Z can be
represented as (As, A)
where As is the sign of Z
and A is the magnitude
of Z.
 The leftmost position, As,
is the sign bit.
 The sign bit is either
positive = 0 or negative =
1
Number
Signed-
Magnitude
+3 0 11
+2 0 10
+1 0 01
+0 0 00
-0 1 00
-1 1 01
-2 1 10
-3 1 11
4
ADDITION ALGORITHM
When the sign of A and B are same, add the magnitudes and attach
the sign of A to the result.
Otherwise compare the magnitudes and subtract the smaller
number from the larger.
 Choose the sign of result to be same as A if A>B
 or the complement of sign of A if A<B
 if A=B subtract B from A and make the sign of result positive
5
SIGNED BIT ADDITION
Operation Add
Magnitudes
Subtract Magnitudes
A>B A<B A=B
( + A ) + ( + B ) + ( A + B )
( - A ) + ( - B ) - ( A + B )
( + A ) + ( - B ) + ( A - B ) - ( B - A ) + ( A - B )
( - A ) + ( + B ) - ( A - B ) + ( B - A ) + ( A - B )
6
Flow Chart for Addition Operation
Start Addition
As = Bs
Ar = A + B
Ars = As
A > B
Ar = A – B
Ars = As
A = B
Ar = 0
Ars = 0
Done
Ar = B – A
Ars = Bs
7
EXAMPLE
 Example of adding two
magnitudes when the
result is the sign of both
operands:
+3 0 011
+ +2 0 010
+5 0 101
-3 1 011
+ +2 0 010
-( +3 0 011
- 2) 1 010
-(1) 1 001
 Example of adding two
magnitudes when the
result is the sign of larger
magnitude
8
SUBTRACTION ALGORITHM
 When the sign of A and B are Different , add the magnitudes and
attach the sign of A to the result.
Otherwise compare the magnitudes and subtract the smaller
number from the larger.
 Choose the sign of result to be same as A if A>B
 or the complement of sign of A if A<B
 if A=B subtract B from A and make the sign of result positive
9
SIGNED BIT SUBTRACTION
Operation Add
Magnitudes
Subtract Magnitudes
A>B A<B A=B
( + A ) - ( - B ) + ( A + B )
( - A ) - ( + B ) - ( A + B )
( + A ) - ( + B ) + ( A - B ) - ( B - A ) + ( A - B )
( - A ) - ( - B ) - ( A - B ) + ( B - A ) + ( A - B )
10
Flow Chart for Subtract Operation
Ar = B – A
Ars = Bs
Start
Subtraction
Bs = Bs’
As = Bs
Ar = A + B
Ars = As
A > B
Ar = A – B
Ars = As
A = B
Ar = 0
Ars = 0
Done
11
EXAMPLE
 Example of Subtracting
two numbers with same
sign bits
+3 0 011
- +2 0 010
+1 0 001
-3 1 011
- +2 0 010
-( +3 0 011
+2) 0 010
-(5) 0 101
 Example of Subtracting
two numbers with
Different sign bits
12
Hardware Algorithm
13
Hardware Implementation
B Register
Complementer
Parallel Adder
A Register
Bs
E
AVF
As Load Sum
Input Carry
M (ModeControl)
Output Carry
M = 0 output = A+B M = 1 output = A+B’+1= A-B
14
EXAMPLE
+3 0 011
- +2 0 010
+( +3 0 011
-2) 1 110
+(1) 0 001
 Example of Subtracting
two numbers with
Different sign bits with
2’s complement
Arithmetic
+3 -> 0011
+2 -> 0010
-2 -> 2’scomp(“+2”)
-> 1110
15
16

Más contenido relacionado

La actualidad más candente

Basic Computer Organization and Design
Basic Computer Organization and DesignBasic Computer Organization and Design
Basic Computer Organization and Designmekind
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-busAnuj Modi
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codesRevathi Subramaniam
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output OrganizationKamal Acharya
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interruptsRam Babu
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transferpriya Nithya
 
Octal to binary encoder
Octal to binary encoderOctal to binary encoder
Octal to binary encoderAjay844
 
Timing and-control-unit
Timing and-control-unitTiming and-control-unit
Timing and-control-unitAnuj Modi
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set ArchitectureDilum Bandara
 
Cache memory
Cache memoryCache memory
Cache memoryAnuj Modi
 

La actualidad más candente (20)

Data Representation
Data RepresentationData Representation
Data Representation
 
MULTIPLEXER
MULTIPLEXERMULTIPLEXER
MULTIPLEXER
 
Basic Computer Organization and Design
Basic Computer Organization and DesignBasic Computer Organization and Design
Basic Computer Organization and Design
 
Instruction codes
Instruction codesInstruction codes
Instruction codes
 
Registers and-common-bus
Registers and-common-busRegisters and-common-bus
Registers and-common-bus
 
pipelining
pipeliningpipelining
pipelining
 
Modes of transfer
Modes of transferModes of transfer
Modes of transfer
 
ADDRESSING MODES
ADDRESSING MODESADDRESSING MODES
ADDRESSING MODES
 
Basic Computer Organization and Design
Basic  Computer  Organization  and  DesignBasic  Computer  Organization  and  Design
Basic Computer Organization and Design
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
 
Microprogrammed Control Unit
Microprogrammed Control UnitMicroprogrammed Control Unit
Microprogrammed Control Unit
 
Addressing sequencing
Addressing sequencingAddressing sequencing
Addressing sequencing
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output Organization
 
8085 interrupts
8085 interrupts8085 interrupts
8085 interrupts
 
Asynchronous data transfer
Asynchronous data transferAsynchronous data transfer
Asynchronous data transfer
 
Octal to binary encoder
Octal to binary encoderOctal to binary encoder
Octal to binary encoder
 
Timing and-control-unit
Timing and-control-unitTiming and-control-unit
Timing and-control-unit
 
Instruction Set Architecture
Instruction Set ArchitectureInstruction Set Architecture
Instruction Set Architecture
 
Cache memory
Cache memoryCache memory
Cache memory
 

Similar a Signed addition and subtraction using binary numbers

index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...mayurjagdale4
 
Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...mayurjagdale4
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptxMtikuTadesse
 
Data representation moris mano ch 03
Data representation   moris mano ch  03Data representation   moris mano ch  03
Data representation moris mano ch 03thearticlenow
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptskatiarrahaman
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfGafryMahmoud
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logicDeepak John
 
ARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.pptARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.pptRAJESH S
 
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsFYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsArti Parab Academics
 
Basic_analysis.ppt
Basic_analysis.pptBasic_analysis.ppt
Basic_analysis.pptSoumyaJ3
 
Adder and Subtractor
Adder and SubtractorAdder and Subtractor
Adder and SubtractorJaydeep Kale
 

Similar a Signed addition and subtraction using binary numbers (20)

Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 
Ch_10.pptx.pdf
Ch_10.pptx.pdfCh_10.pptx.pdf
Ch_10.pptx.pdf
 
computer arithmatic
computer arithmaticcomputer arithmatic
computer arithmatic
 
index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...index of all of the financial accounts in a company's general ledger. In shor...
index of all of the financial accounts in a company's general ledger. In shor...
 
Ch3
Ch3Ch3
Ch3
 
Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...Computer Architecture refers to those attributes of a system that have a dire...
Computer Architecture refers to those attributes of a system that have a dire...
 
DATA REPRESENTATION
DATA  REPRESENTATIONDATA  REPRESENTATION
DATA REPRESENTATION
 
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
2 Computer Arithmetic_hhbyhbjhhjjjjjb41.pptx
 
Data representation moris mano ch 03
Data representation   moris mano ch  03Data representation   moris mano ch  03
Data representation moris mano ch 03
 
Datarepresentation2
Datarepresentation2Datarepresentation2
Datarepresentation2
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Comp Arithmetic Basic.ppt
Comp Arithmetic Basic.pptComp Arithmetic Basic.ppt
Comp Arithmetic Basic.ppt
 
Unit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdfUnit-8-Computer-Arithmetic.pdf
Unit-8-Computer-Arithmetic.pdf
 
Combinational and sequential logic
Combinational and sequential logicCombinational and sequential logic
Combinational and sequential logic
 
ARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.pptARITHMETIC LOGIC UNIT.ppt
ARITHMETIC LOGIC UNIT.ppt
 
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic CircuitsFYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
FYBSC IT Digital Electronics Unit III Chapter II Arithmetic Circuits
 
Basic_analysis.ppt
Basic_analysis.pptBasic_analysis.ppt
Basic_analysis.ppt
 
Chapter 4
Chapter 4Chapter 4
Chapter 4
 
Adder and Subtractor
Adder and SubtractorAdder and Subtractor
Adder and Subtractor
 
Computer arithmetic
Computer arithmeticComputer arithmetic
Computer arithmetic
 

Más de Keyur Vadodariya

Más de Keyur Vadodariya (7)

Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And Demultiplexing
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
I/O Management
I/O ManagementI/O Management
I/O Management
 
Ocean Acidification
Ocean AcidificationOcean Acidification
Ocean Acidification
 
Polar Curves
Polar CurvesPolar Curves
Polar Curves
 
Laser And It's Application
Laser And It's ApplicationLaser And It's Application
Laser And It's Application
 
Air Compressors
Air CompressorsAir Compressors
Air Compressors
 

Último

Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...anjaliyadav012327
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 

Último (20)

Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
JAPAN: ORGANISATION OF PMDA, PHARMACEUTICAL LAWS & REGULATIONS, TYPES OF REGI...
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 

Signed addition and subtraction using binary numbers

  • 1. SARVAJANIK COLLEGE OF ENGINEERING AND TECHNOLOGY COMPUTER ENGINEERING DEPARTMENT B. E.-II, CO-E, SEM-IV (EVEN-2019) ALA Presentation on “Signed Addition And Subtraction” Subject Name : Computer Organisation(2140702) Prepared and Presented by (Group No. : 14 ) Pathik Thakor (170420107557) Jasmin Thummar (170420107558) Uttam Thummar (170420107559) Keyur Vadodariya (170420107561) 1
  • 2. Overview • Representation of Number • Addition & Subtraction Algorithm • Flow Chart • Examples • Hardware implementation 2
  • 3. SIGNED BIT REPRESENTATION Example: Represent +9 and -9 in 7 bit-binary number Only one way to represent + 9 ==> 0 001001 Three different ways to represent - 9: In signed-magnitude: 1 001001 In signed-1's complement: 1 110110 In signed-2's complement: 1 110111 Representation of both positive and negative numbers - Following 3 representations Signed magnitude representation Signed 1's complement representation Signed 2's complement representation 3
  • 4. Sign-magnitude number  A sign-magnitude number Z can be represented as (As, A) where As is the sign of Z and A is the magnitude of Z.  The leftmost position, As, is the sign bit.  The sign bit is either positive = 0 or negative = 1 Number Signed- Magnitude +3 0 11 +2 0 10 +1 0 01 +0 0 00 -0 1 00 -1 1 01 -2 1 10 -3 1 11 4
  • 5. ADDITION ALGORITHM When the sign of A and B are same, add the magnitudes and attach the sign of A to the result. Otherwise compare the magnitudes and subtract the smaller number from the larger.  Choose the sign of result to be same as A if A>B  or the complement of sign of A if A<B  if A=B subtract B from A and make the sign of result positive 5
  • 6. SIGNED BIT ADDITION Operation Add Magnitudes Subtract Magnitudes A>B A<B A=B ( + A ) + ( + B ) + ( A + B ) ( - A ) + ( - B ) - ( A + B ) ( + A ) + ( - B ) + ( A - B ) - ( B - A ) + ( A - B ) ( - A ) + ( + B ) - ( A - B ) + ( B - A ) + ( A - B ) 6
  • 7. Flow Chart for Addition Operation Start Addition As = Bs Ar = A + B Ars = As A > B Ar = A – B Ars = As A = B Ar = 0 Ars = 0 Done Ar = B – A Ars = Bs 7
  • 8. EXAMPLE  Example of adding two magnitudes when the result is the sign of both operands: +3 0 011 + +2 0 010 +5 0 101 -3 1 011 + +2 0 010 -( +3 0 011 - 2) 1 010 -(1) 1 001  Example of adding two magnitudes when the result is the sign of larger magnitude 8
  • 9. SUBTRACTION ALGORITHM  When the sign of A and B are Different , add the magnitudes and attach the sign of A to the result. Otherwise compare the magnitudes and subtract the smaller number from the larger.  Choose the sign of result to be same as A if A>B  or the complement of sign of A if A<B  if A=B subtract B from A and make the sign of result positive 9
  • 10. SIGNED BIT SUBTRACTION Operation Add Magnitudes Subtract Magnitudes A>B A<B A=B ( + A ) - ( - B ) + ( A + B ) ( - A ) - ( + B ) - ( A + B ) ( + A ) - ( + B ) + ( A - B ) - ( B - A ) + ( A - B ) ( - A ) - ( - B ) - ( A - B ) + ( B - A ) + ( A - B ) 10
  • 11. Flow Chart for Subtract Operation Ar = B – A Ars = Bs Start Subtraction Bs = Bs’ As = Bs Ar = A + B Ars = As A > B Ar = A – B Ars = As A = B Ar = 0 Ars = 0 Done 11
  • 12. EXAMPLE  Example of Subtracting two numbers with same sign bits +3 0 011 - +2 0 010 +1 0 001 -3 1 011 - +2 0 010 -( +3 0 011 +2) 0 010 -(5) 0 101  Example of Subtracting two numbers with Different sign bits 12
  • 14. Hardware Implementation B Register Complementer Parallel Adder A Register Bs E AVF As Load Sum Input Carry M (ModeControl) Output Carry M = 0 output = A+B M = 1 output = A+B’+1= A-B 14
  • 15. EXAMPLE +3 0 011 - +2 0 010 +( +3 0 011 -2) 1 110 +(1) 0 001  Example of Subtracting two numbers with Different sign bits with 2’s complement Arithmetic +3 -> 0011 +2 -> 0010 -2 -> 2’scomp(“+2”) -> 1110 15
  • 16. 16