SlideShare a Scribd company logo
1 of 3
Chapter3 Notes: Hennessy | Arithmetic for Computers 1
Chapter 3 (Hennessy 4th Ed): Arithmetic for Computers
Supplement(s):
Objectives:
 Introduction
 Addition and Subtraction
 Multiplication
 Division
 Floating Point
 Parallelism and Computer Arithmetic
 Associativity
 Fallacies and Pitfalls
 Concluding Remarks
The goal of this chapter includes representationof realnumbers, what happens ifanoperation creates a number bigger thancanbe represented, howdoes
hardware reallymultiplyor divide numbers, arithmetic algorithms, hardware that follows these algorithms, and the implications of all this for instruction sets.
Content
Addition and Subtraction
 In addition, digits are addedbit bybit from right to left, withcarries passedto the next digit to the left, just as you woulddo byhand. Subtraction
uses addition:the appropriate operand is simplynegated before being added.
 Overflow occurs whenthe result fromanoperation cannot be representedwiththe available hardware, in thiscase a 32-bit word. When can
overflowoccur in addition? When addingoperands withdifferent signs, overflow cannot occur. There are similar restrictions to the occurrence of
overflowduringsubtract, but it’s just the opposite principle: whenthe signs of the operands are the same, overflow cannot occur (as when we
subtract operands of the same sign we endupbyadding operands of different signs). Knowing when overflow cannot occur in additionand
subtraction is all well and good, but howdo we detect it whenit does occur? Clearly, adding or subtracting two 32-bit numbers canyielda result that
needs 33 bits to be fullyexpressed. The lack of a 33rd bit means that whenoverflow occurs, the sign bit is set withthe value of the result insteadof
the proper signof the result. Since we need just one extra bit, onlythe signbit can be wrong. Hence, overflow occurs whenadding two positive
numbers andthe sum is negative, or vice versa. This means a carryout occurredintothe signbit.
 Overflow occurs insubtraction whenwe subtract a negative number from a positive number and get a negative result, or when w e subtract a
positive number from a negative number and get a positive result. Thismeans a borrow occurred fromthe signbit. Figure 3.2 shows the
Chapter3 Notes: Hennessy | Arithmetic for Computers 2
combination ofoperations, operands, andresults that indicate anoverflow.
 We have just seenhow to detect overflowfor two’s complement numbers ina computer. What about overflow withunsignedintegers? Unsigned
integers are commonlyusedfor memoryaddresseswhere overflows are ignored. The computer designer must therefore provide a wayto ignore
overflowinsome casesandto recognize it inothers. The MIPS solutionis to have twokinds ofarithmetic instructions to re cognize the two choices:
■■ Add (add), addimmediate (addi), andsubtract (sub)cause exceptions onoverflow.
■■ Add unsigned (addu), add immediate unsigned(addiu), and subtract unsigned (subu)do not cause exceptions onoverflow.
 Because Cignores overflows, the MIPSC compilers willalways generate the unsigned versions of the arithmetic instructions addu, addiu, andsubu,
no matter what the type ofthe variables. The MIPSFortrancompilers, however, pick the appropriate arithmetic instructions, depending onthe type
of the operands.
 Appendix Cdescribes the hardware that performs additionandsubtraction, which is calledanArithmetic Logic Unit or ALU (It is the hardware that
performs addition, subtraction, and usuallylogical operations such as AND and OR.)
 Although some languageslike CandJava ignore integer overflow, languages like Ada andFortranrequire that the programbe notified. The
programmer or the programming environment must then decide what to dowhenoverflowoccurs.
 MIPS detects overflow withanexception, also calledaninterrupt onmanycomputers. An exception or interrupt is essentiallyanunscheduled
procedure call. The addressof the instructionthat overflowedis saved ina register, andthe computer jumps to a predefined address to invoke the
appropriate routine for that exception. The interrupted addressis savedsothat in some situations the programcancontinue after corrective code is
executed. (Section4.9 covers exceptions in more detail;Chapters 5 and6 describe other situations where exceptions andinterrupts occur.)
 MIPS includes a register calledthe exception programcounter (EPC) to containthe address ofthe instructionthat causedthe exception. The
instruction move fromsystemcontrol (mfc0) is used to copyEPCinto a general-purpose register sothat MIPS software hasthe optionof returning to
the offending instructionvia a jumpregister instruction(The mfc0 (move from coprocessor 0) instruction loads data froma coprocessor 0 register
into a CPU register – uwm.edu).
Arithmetic for Multimedia (relevant summary)
 Manygraphics systems originallyused8 bits to represent eachof the three primarycolors plus 8 bits for a locationof a pixel.
 Architects recognizedthat manygraphics andaudioapplications wouldperform the same operationon vectors of thisdata. Bypartitioningthe carry
chains withina 64-bit adder, a processor couldperform simultaneous operations onshort vectors ofeight 8-bit operands, four 16-bit operands, or
two 32-bit operands. The cost of such partitionedadders was small. These extensions have beencalledvector or SIMD, for single instruction,
multiple data (see Section 2.17 and Chapter 7).
 One feature not generallyfoundingeneral-purpose microprocessors is saturating operations. Saturation means that when a calculation overflows,
the result is set to the largest positive number or most negative number, rather than a modulocalculationas intwo’s complement arithmetic.
Saturationis likelywhat you want for mediaoperations.
 It’s easyto detect overflowinunsignednumbers, althoughthese are almost always ignored because programs don’t want to detect overflow for
address arithmetic, the most commonuse of natural numbers. Two’s complement presents a greater challenge, yet some software systems require
detection ofoverflow, sotodayall computers have a wayto detect it.
 The risingpopularityof multimediaapplications led to arithmetic instructions that support narrower operations that caneasilyoperate inparallel.
 Elaboration: We had saidthat youcopyEPCinto a register via mfc0 andthenreturnto the interruptedcode via jumpregister. This leads to an
interesting question:since you must first transfer EPCto a register to use withjumpregister, howcanjumpregister return to the interruptedcode
Chapter3 Notes: Hennessy | Arithmetic for Computers 3
and restore the original valuesof all registers?Either you restore the oldregisters first, therebydestroyingyour return address fromEPC, which you
placedina register for use injump register, or you restore all registers but the one withthe return addresssothat you canjump—meaningan
exceptionwouldresult inchanging that one register at anytime duringprogram execution!Neither optionis satisfactory. To rescue the hardware
from this dilemma, MIPSprogrammers agreedto reserve registers $k0 and $k1 for the operating system;these registers are not restoredon
exceptions. Just as the MIPS compilers avoidusingregister $at so that the assembler canuse it as a temporaryregister (see Hardware/Software
Interface in Section2.10), compilers also abstainfrom using registers $k0 and$k1 to make them available for the operating system. Exception
routines place the return address in one ofthese registers andthenuse jump register to restore the instruction address.
 Elaboration: The speedof additionis increasedbydetermining the carryin to the high-order bits sooner. There are a varietyof schemes to
anticipate the carryso that the worst-case scenariois a functionof the log2 of the number of bits in the adder. These anticipatorysignals are faster
because theygo throughfewer gates in sequence, but it takes manymore gates to anticipate the proper carry. The most popular is carrylookahead,
which Section C.6 in Appendix Con the CD describes.
Multiplication

ASSOCIATED CONTENT
 XXX
To be cleared
Further Reading
 XXX
More Research
 XXX

More Related Content

What's hot

Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
IJERD Editor
 

What's hot (14)

Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
Comparison of Adders for optimized Exponent Addition circuit in IEEE754 Float...
 
Instruction set (prasenjit dey)
Instruction set (prasenjit dey)Instruction set (prasenjit dey)
Instruction set (prasenjit dey)
 
Types of Instruction Format
Types of Instruction FormatTypes of Instruction Format
Types of Instruction Format
 
Pointers lesson 3 (data types and pointer arithmetics)
Pointers lesson 3 (data types and pointer arithmetics)Pointers lesson 3 (data types and pointer arithmetics)
Pointers lesson 3 (data types and pointer arithmetics)
 
COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6COMPUTER ORGANIZATION NOTES Unit 6
COMPUTER ORGANIZATION NOTES Unit 6
 
Memory Reference Instructions
Memory Reference InstructionsMemory Reference Instructions
Memory Reference Instructions
 
Number formats for signals and coefficients in DSP system
Number formats for signals and coefficients in DSP systemNumber formats for signals and coefficients in DSP system
Number formats for signals and coefficients in DSP system
 
instruction format and addressing modes
instruction format and addressing modesinstruction format and addressing modes
instruction format and addressing modes
 
Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)Instruction Set Architecture (ISA)
Instruction Set Architecture (ISA)
 
Lab 1:c++
Lab 1:c++Lab 1:c++
Lab 1:c++
 
Intermediate code representations
Intermediate code representationsIntermediate code representations
Intermediate code representations
 
A nice 64-bit error in C
A  nice 64-bit error in CA  nice 64-bit error in C
A nice 64-bit error in C
 
Computer architecture instruction formats
Computer architecture instruction formatsComputer architecture instruction formats
Computer architecture instruction formats
 
Explain Half Adder and Full Adder with Truth Table
Explain Half Adder and Full Adder with Truth TableExplain Half Adder and Full Adder with Truth Table
Explain Half Adder and Full Adder with Truth Table
 

Viewers also liked (10)

July_13_2015_Adena_Monitor Final
July_13_2015_Adena_Monitor FinalJuly_13_2015_Adena_Monitor Final
July_13_2015_Adena_Monitor Final
 
鑽石的切工
鑽石的切工鑽石的切工
鑽石的切工
 
CVEnSaugeNolwenn
CVEnSaugeNolwennCVEnSaugeNolwenn
CVEnSaugeNolwenn
 
Bättre trafik billigare skärgårdslinjen 2.0 får publiceras fredag 5.9 2014...
Bättre trafik billigare  skärgårdslinjen 2.0   får publiceras fredag 5.9 2014...Bättre trafik billigare  skärgårdslinjen 2.0   får publiceras fredag 5.9 2014...
Bättre trafik billigare skärgårdslinjen 2.0 får publiceras fredag 5.9 2014...
 
Presentación1
Presentación1Presentación1
Presentación1
 
2016 sep
2016 sep2016 sep
2016 sep
 
Manual de procedimientos 2016
Manual de procedimientos 2016Manual de procedimientos 2016
Manual de procedimientos 2016
 
The Real World April 2016
The Real World April 2016The Real World April 2016
The Real World April 2016
 
Kristiina ja tom grahn houkuttelevat lisää väkeä brändöhön ahvenanmaalle
Kristiina ja tom grahn houkuttelevat lisää väkeä brändöhön ahvenanmaalleKristiina ja tom grahn houkuttelevat lisää väkeä brändöhön ahvenanmaalle
Kristiina ja tom grahn houkuttelevat lisää väkeä brändöhön ahvenanmaalle
 
Atpl book-3-electrics-and-electronics
Atpl book-3-electrics-and-electronicsAtpl book-3-electrics-and-electronics
Atpl book-3-electrics-and-electronics
 

Similar to Hennchthree 160912095304

Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computers
Bảo Hoang
 
The Role Of Software And Hardware As A Common Part Of The...
The Role Of Software And Hardware As A Common Part Of The...The Role Of Software And Hardware As A Common Part Of The...
The Role Of Software And Hardware As A Common Part Of The...
Sheena Crouch
 

Similar to Hennchthree 160912095304 (20)

Arithmetic for Computers.ppt
Arithmetic for Computers.pptArithmetic for Computers.ppt
Arithmetic for Computers.ppt
 
Chapter 03 arithmetic for computers
Chapter 03   arithmetic for computersChapter 03   arithmetic for computers
Chapter 03 arithmetic for computers
 
Unit ii ca--arithmetic
Unit ii ca--arithmeticUnit ii ca--arithmetic
Unit ii ca--arithmetic
 
The Role Of Software And Hardware As A Common Part Of The...
The Role Of Software And Hardware As A Common Part Of The...The Role Of Software And Hardware As A Common Part Of The...
The Role Of Software And Hardware As A Common Part Of The...
 
Computer Arithmetic Algorithm Arithmetic.pptx
Computer Arithmetic Algorithm Arithmetic.pptxComputer Arithmetic Algorithm Arithmetic.pptx
Computer Arithmetic Algorithm Arithmetic.pptx
 
UNIT 2_ESD.pdf
UNIT 2_ESD.pdfUNIT 2_ESD.pdf
UNIT 2_ESD.pdf
 
C++11 and 64-bit Issues
C++11 and 64-bit IssuesC++11 and 64-bit Issues
C++11 and 64-bit Issues
 
Datapath Design of Computer Architecture
Datapath Design of Computer ArchitectureDatapath Design of Computer Architecture
Datapath Design of Computer Architecture
 
Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...Development of a static code analyzer for detecting errors of porting program...
Development of a static code analyzer for detecting errors of porting program...
 
CAO-Unit-I.pptx
CAO-Unit-I.pptxCAO-Unit-I.pptx
CAO-Unit-I.pptx
 
Numerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagationNumerical analysis using Scilab: Error analysis and propagation
Numerical analysis using Scilab: Error analysis and propagation
 
A collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programsA collection of examples of 64 bit errors in real programs
A collection of examples of 64 bit errors in real programs
 
Lesson 26. Optimization of 64-bit programs
Lesson 26. Optimization of 64-bit programsLesson 26. Optimization of 64-bit programs
Lesson 26. Optimization of 64-bit programs
 
VTU 4TH SEM CSE COMPUTER ORGANIZATION SOLVED PAPERS OF JUNE-2013 JUNE-2014 & ...
VTU 4TH SEM CSE COMPUTER ORGANIZATION SOLVED PAPERS OF JUNE-2013 JUNE-2014 & ...VTU 4TH SEM CSE COMPUTER ORGANIZATION SOLVED PAPERS OF JUNE-2013 JUNE-2014 & ...
VTU 4TH SEM CSE COMPUTER ORGANIZATION SOLVED PAPERS OF JUNE-2013 JUNE-2014 & ...
 
Static code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applicationsStatic code analysis for verification of the 64-bit applications
Static code analysis for verification of the 64-bit applications
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 
Fabric design pattern feeding through human machine interface (hmi) for an el...
Fabric design pattern feeding through human machine interface (hmi) for an el...Fabric design pattern feeding through human machine interface (hmi) for an el...
Fabric design pattern feeding through human machine interface (hmi) for an el...
 
computer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAKcomputer architecture and the fetch execute cycle By ZAK
computer architecture and the fetch execute cycle By ZAK
 
1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK1.3.2 computer architecture and the fetch execute cycle By ZAK
1.3.2 computer architecture and the fetch execute cycle By ZAK
 
A Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real ProgramsA Collection of Examples of 64-bit Errors in Real Programs
A Collection of Examples of 64-bit Errors in Real Programs
 

More from marangburu42

More from marangburu42 (20)

Hol
HolHol
Hol
 
Write miss
Write missWrite miss
Write miss
 
Hennchthree 161102111515
Hennchthree 161102111515Hennchthree 161102111515
Hennchthree 161102111515
 
Hennchthree
HennchthreeHennchthree
Hennchthree
 
Sequential circuits
Sequential circuitsSequential circuits
Sequential circuits
 
Combinational circuits
Combinational circuitsCombinational circuits
Combinational circuits
 
Sequential circuits
Sequential circuitsSequential circuits
Sequential circuits
 
Combinational circuits
Combinational circuitsCombinational circuits
Combinational circuits
 
Karnaugh mapping allaboutcircuits
Karnaugh mapping allaboutcircuitsKarnaugh mapping allaboutcircuits
Karnaugh mapping allaboutcircuits
 
Aac boolean formulae
Aac   boolean formulaeAac   boolean formulae
Aac boolean formulae
 
Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858Virtualmemoryfinal 161019175858
Virtualmemoryfinal 161019175858
 
Io systems final
Io systems finalIo systems final
Io systems final
 
File system interfacefinal
File system interfacefinalFile system interfacefinal
File system interfacefinal
 
File systemimplementationfinal
File systemimplementationfinalFile systemimplementationfinal
File systemimplementationfinal
 
Mass storage structurefinal
Mass storage structurefinalMass storage structurefinal
Mass storage structurefinal
 
All aboutcircuits karnaugh maps
All aboutcircuits karnaugh mapsAll aboutcircuits karnaugh maps
All aboutcircuits karnaugh maps
 
Virtual memoryfinal
Virtual memoryfinalVirtual memoryfinal
Virtual memoryfinal
 
Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029Mainmemoryfinal 161019122029
Mainmemoryfinal 161019122029
 
Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904Virtualmemorypre final-formatting-161019022904
Virtualmemorypre final-formatting-161019022904
 
Process synchronizationfinal
Process synchronizationfinalProcess synchronizationfinal
Process synchronizationfinal
 

Recently uploaded

FSSAI.ppt Food safety standards act in RAFN
FSSAI.ppt Food safety standards act in RAFNFSSAI.ppt Food safety standards act in RAFN
FSSAI.ppt Food safety standards act in RAFN
Lokesh Kothari
 
一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理
一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理
一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理
hwoudye
 
一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证
一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证
一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证
funaxa
 
如何办理新加坡管理大学毕业证成绩单留信学历认证
如何办理新加坡管理大学毕业证成绩单留信学历认证如何办理新加坡管理大学毕业证成绩单留信学历认证
如何办理新加坡管理大学毕业证成绩单留信学历认证
zg99vwgda
 
Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)
Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)
Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)
Lokesh Kothari
 
一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理
一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理
一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理
hwoudye
 
一比一原版查尔斯特大学毕业证如何办理
一比一原版查尔斯特大学毕业证如何办理一比一原版查尔斯特大学毕业证如何办理
一比一原版查尔斯特大学毕业证如何办理
hwoudye
 
LESSON 1 PREPARE AND COOKING MEAT GRADE 10
LESSON 1 PREPARE AND COOKING MEAT GRADE 10LESSON 1 PREPARE AND COOKING MEAT GRADE 10
LESSON 1 PREPARE AND COOKING MEAT GRADE 10
manwithoutapfp
 

Recently uploaded (17)

Jual Obat Aborsi Sorong, Wa : 0822/2310/9953 Apotik Jual Obat Cytotec Di Sorong
Jual Obat Aborsi Sorong, Wa : 0822/2310/9953 Apotik Jual Obat Cytotec Di SorongJual Obat Aborsi Sorong, Wa : 0822/2310/9953 Apotik Jual Obat Cytotec Di Sorong
Jual Obat Aborsi Sorong, Wa : 0822/2310/9953 Apotik Jual Obat Cytotec Di Sorong
 
Food Preservatives Market by Product Type, Distribution Channel, End User 202...
Food Preservatives Market by Product Type, Distribution Channel, End User 202...Food Preservatives Market by Product Type, Distribution Channel, End User 202...
Food Preservatives Market by Product Type, Distribution Channel, End User 202...
 
FSSAI.ppt Food safety standards act in RAFN
FSSAI.ppt Food safety standards act in RAFNFSSAI.ppt Food safety standards act in RAFN
FSSAI.ppt Food safety standards act in RAFN
 
一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理
一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理
一比一原版卡尔顿大学毕业证(carleton毕业证)学历认证靠谱办理
 
一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证
一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证
一比一原版(LMU毕业证书)英国伦敦都市大学毕业证学位证可查学历认证
 
原版1:1定制(IC大学毕业证)帝国理工学院大学毕业证国外文凭复刻成绩单#电子版制作#留信入库#多年经营绝对保证质量
原版1:1定制(IC大学毕业证)帝国理工学院大学毕业证国外文凭复刻成绩单#电子版制作#留信入库#多年经营绝对保证质量原版1:1定制(IC大学毕业证)帝国理工学院大学毕业证国外文凭复刻成绩单#电子版制作#留信入库#多年经营绝对保证质量
原版1:1定制(IC大学毕业证)帝国理工学院大学毕业证国外文凭复刻成绩单#电子版制作#留信入库#多年经营绝对保证质量
 
如何办理新加坡管理大学毕业证成绩单留信学历认证
如何办理新加坡管理大学毕业证成绩单留信学历认证如何办理新加坡管理大学毕业证成绩单留信学历认证
如何办理新加坡管理大学毕业证成绩单留信学历认证
 
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
Abortion pills in Jeddah +966572737505 <> buy cytotec <> unwanted kit Saudi A...
 
Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)
Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)
Medical Foods final.ppt (Regulatory Aspects of Food & Nutraceiticals)
 
NO1 Top Online Amil Baba in Rawalpindi Contact Number Amil in Rawalpindi Kala...
NO1 Top Online Amil Baba in Rawalpindi Contact Number Amil in Rawalpindi Kala...NO1 Top Online Amil Baba in Rawalpindi Contact Number Amil in Rawalpindi Kala...
NO1 Top Online Amil Baba in Rawalpindi Contact Number Amil in Rawalpindi Kala...
 
CLASSIFICATION AND PROPERTIES OF FATS AND THEIR FUNCTIONS
CLASSIFICATION AND PROPERTIES OF FATS AND THEIR FUNCTIONSCLASSIFICATION AND PROPERTIES OF FATS AND THEIR FUNCTIONS
CLASSIFICATION AND PROPERTIES OF FATS AND THEIR FUNCTIONS
 
HYDROPONICS cratky method 1234567890qwew
HYDROPONICS  cratky  method 1234567890qwewHYDROPONICS  cratky  method 1234567890qwew
HYDROPONICS cratky method 1234567890qwew
 
The Codex Alimentarius Commission (CAC).
The Codex Alimentarius Commission (CAC).The Codex Alimentarius Commission (CAC).
The Codex Alimentarius Commission (CAC).
 
一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理
一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理
一比一原版(uOttawa毕业证书)加拿大渥太华大学毕业证如何办理
 
一比一原版查尔斯特大学毕业证如何办理
一比一原版查尔斯特大学毕业证如何办理一比一原版查尔斯特大学毕业证如何办理
一比一原版查尔斯特大学毕业证如何办理
 
LESSON 1 PREPARE AND COOKING MEAT GRADE 10
LESSON 1 PREPARE AND COOKING MEAT GRADE 10LESSON 1 PREPARE AND COOKING MEAT GRADE 10
LESSON 1 PREPARE AND COOKING MEAT GRADE 10
 
PRESTAIR MANUFACTURER OF DISPLAY COUNTER
PRESTAIR MANUFACTURER OF DISPLAY COUNTERPRESTAIR MANUFACTURER OF DISPLAY COUNTER
PRESTAIR MANUFACTURER OF DISPLAY COUNTER
 

Hennchthree 160912095304

  • 1. Chapter3 Notes: Hennessy | Arithmetic for Computers 1 Chapter 3 (Hennessy 4th Ed): Arithmetic for Computers Supplement(s): Objectives:  Introduction  Addition and Subtraction  Multiplication  Division  Floating Point  Parallelism and Computer Arithmetic  Associativity  Fallacies and Pitfalls  Concluding Remarks The goal of this chapter includes representationof realnumbers, what happens ifanoperation creates a number bigger thancanbe represented, howdoes hardware reallymultiplyor divide numbers, arithmetic algorithms, hardware that follows these algorithms, and the implications of all this for instruction sets. Content Addition and Subtraction  In addition, digits are addedbit bybit from right to left, withcarries passedto the next digit to the left, just as you woulddo byhand. Subtraction uses addition:the appropriate operand is simplynegated before being added.  Overflow occurs whenthe result fromanoperation cannot be representedwiththe available hardware, in thiscase a 32-bit word. When can overflowoccur in addition? When addingoperands withdifferent signs, overflow cannot occur. There are similar restrictions to the occurrence of overflowduringsubtract, but it’s just the opposite principle: whenthe signs of the operands are the same, overflow cannot occur (as when we subtract operands of the same sign we endupbyadding operands of different signs). Knowing when overflow cannot occur in additionand subtraction is all well and good, but howdo we detect it whenit does occur? Clearly, adding or subtracting two 32-bit numbers canyielda result that needs 33 bits to be fullyexpressed. The lack of a 33rd bit means that whenoverflow occurs, the sign bit is set withthe value of the result insteadof the proper signof the result. Since we need just one extra bit, onlythe signbit can be wrong. Hence, overflow occurs whenadding two positive numbers andthe sum is negative, or vice versa. This means a carryout occurredintothe signbit.  Overflow occurs insubtraction whenwe subtract a negative number from a positive number and get a negative result, or when w e subtract a positive number from a negative number and get a positive result. Thismeans a borrow occurred fromthe signbit. Figure 3.2 shows the
  • 2. Chapter3 Notes: Hennessy | Arithmetic for Computers 2 combination ofoperations, operands, andresults that indicate anoverflow.  We have just seenhow to detect overflowfor two’s complement numbers ina computer. What about overflow withunsignedintegers? Unsigned integers are commonlyusedfor memoryaddresseswhere overflows are ignored. The computer designer must therefore provide a wayto ignore overflowinsome casesandto recognize it inothers. The MIPS solutionis to have twokinds ofarithmetic instructions to re cognize the two choices: ■■ Add (add), addimmediate (addi), andsubtract (sub)cause exceptions onoverflow. ■■ Add unsigned (addu), add immediate unsigned(addiu), and subtract unsigned (subu)do not cause exceptions onoverflow.  Because Cignores overflows, the MIPSC compilers willalways generate the unsigned versions of the arithmetic instructions addu, addiu, andsubu, no matter what the type ofthe variables. The MIPSFortrancompilers, however, pick the appropriate arithmetic instructions, depending onthe type of the operands.  Appendix Cdescribes the hardware that performs additionandsubtraction, which is calledanArithmetic Logic Unit or ALU (It is the hardware that performs addition, subtraction, and usuallylogical operations such as AND and OR.)  Although some languageslike CandJava ignore integer overflow, languages like Ada andFortranrequire that the programbe notified. The programmer or the programming environment must then decide what to dowhenoverflowoccurs.  MIPS detects overflow withanexception, also calledaninterrupt onmanycomputers. An exception or interrupt is essentiallyanunscheduled procedure call. The addressof the instructionthat overflowedis saved ina register, andthe computer jumps to a predefined address to invoke the appropriate routine for that exception. The interrupted addressis savedsothat in some situations the programcancontinue after corrective code is executed. (Section4.9 covers exceptions in more detail;Chapters 5 and6 describe other situations where exceptions andinterrupts occur.)  MIPS includes a register calledthe exception programcounter (EPC) to containthe address ofthe instructionthat causedthe exception. The instruction move fromsystemcontrol (mfc0) is used to copyEPCinto a general-purpose register sothat MIPS software hasthe optionof returning to the offending instructionvia a jumpregister instruction(The mfc0 (move from coprocessor 0) instruction loads data froma coprocessor 0 register into a CPU register – uwm.edu). Arithmetic for Multimedia (relevant summary)  Manygraphics systems originallyused8 bits to represent eachof the three primarycolors plus 8 bits for a locationof a pixel.  Architects recognizedthat manygraphics andaudioapplications wouldperform the same operationon vectors of thisdata. Bypartitioningthe carry chains withina 64-bit adder, a processor couldperform simultaneous operations onshort vectors ofeight 8-bit operands, four 16-bit operands, or two 32-bit operands. The cost of such partitionedadders was small. These extensions have beencalledvector or SIMD, for single instruction, multiple data (see Section 2.17 and Chapter 7).  One feature not generallyfoundingeneral-purpose microprocessors is saturating operations. Saturation means that when a calculation overflows, the result is set to the largest positive number or most negative number, rather than a modulocalculationas intwo’s complement arithmetic. Saturationis likelywhat you want for mediaoperations.  It’s easyto detect overflowinunsignednumbers, althoughthese are almost always ignored because programs don’t want to detect overflow for address arithmetic, the most commonuse of natural numbers. Two’s complement presents a greater challenge, yet some software systems require detection ofoverflow, sotodayall computers have a wayto detect it.  The risingpopularityof multimediaapplications led to arithmetic instructions that support narrower operations that caneasilyoperate inparallel.  Elaboration: We had saidthat youcopyEPCinto a register via mfc0 andthenreturnto the interruptedcode via jumpregister. This leads to an interesting question:since you must first transfer EPCto a register to use withjumpregister, howcanjumpregister return to the interruptedcode
  • 3. Chapter3 Notes: Hennessy | Arithmetic for Computers 3 and restore the original valuesof all registers?Either you restore the oldregisters first, therebydestroyingyour return address fromEPC, which you placedina register for use injump register, or you restore all registers but the one withthe return addresssothat you canjump—meaningan exceptionwouldresult inchanging that one register at anytime duringprogram execution!Neither optionis satisfactory. To rescue the hardware from this dilemma, MIPSprogrammers agreedto reserve registers $k0 and $k1 for the operating system;these registers are not restoredon exceptions. Just as the MIPS compilers avoidusingregister $at so that the assembler canuse it as a temporaryregister (see Hardware/Software Interface in Section2.10), compilers also abstainfrom using registers $k0 and$k1 to make them available for the operating system. Exception routines place the return address in one ofthese registers andthenuse jump register to restore the instruction address.  Elaboration: The speedof additionis increasedbydetermining the carryin to the high-order bits sooner. There are a varietyof schemes to anticipate the carryso that the worst-case scenariois a functionof the log2 of the number of bits in the adder. These anticipatorysignals are faster because theygo throughfewer gates in sequence, but it takes manymore gates to anticipate the proper carry. The most popular is carrylookahead, which Section C.6 in Appendix Con the CD describes. Multiplication  ASSOCIATED CONTENT  XXX To be cleared Further Reading  XXX More Research  XXX