計(jì)算機(jī)組成結(jié)構(gòu) week02-3_第1頁(yè)
計(jì)算機(jī)組成結(jié)構(gòu) week02-3_第2頁(yè)
計(jì)算機(jī)組成結(jié)構(gòu) week02-3_第3頁(yè)
計(jì)算機(jī)組成結(jié)構(gòu) week02-3_第4頁(yè)
計(jì)算機(jī)組成結(jié)構(gòu) week02-3_第5頁(yè)
已閱讀5頁(yè),還剩43頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、5/3/2022CDA31001Outline Announcement Review Unsigned and signed number representations Floating point number representation IEEE 754 standard Instruction set architecture concept5/3/2022CDA31002Announcement Program examples (C or MIPS) are available and will be available at /liux

2、/courses/cda3100/inclassexamples/ 1/12/2015 12:55:01 PMweek02-3.ppt3 The positive half from 0 to 2,147,483,647 The negative half from -2,147,483,648 to -132 Bit Signed Numbers in Twos Complement1/12/2015 12:55:26 PMweek02-3.ppt4General Numbering System Base X In base X, the value of Note the formula

3、 is also valid for a floating point number The value of 011ddddnn0110011110)0(dXdXdXdXXdXdXdXdXdnnnnnnniii21011.ddddddnn332211001111XdXdXdXdXdXdXdXdnnnnnniii1/12/2015 12:56:32 PMweek02-3.ppt5Unsigned Examples 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75 3F.3hex = 316 + 15 160 + 316-1 = 63.18751/12/2015 12:

4、58:12 PMweek02-3.ppt6Decimal to Binary Floating Point Given a floating number in decimal, how to find its binary floating point representation? Lets take 0.1ten as example33221100111122222222ddddddddnnnnnniii1/12/2015 1:00:16 PMweek02-3.ppt7Example Convert 0.1ten to binary floating number00 0 0 1 1

5、0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 10 4 . 022 . 01 2 . 126 . 01 6 . 128 . 00 8 . 024 . 00 4 . 022 . 00 2 . 021 . 01/12/2015 1:02:04 PMweek02-3.ppt8How to Convert Decimal to Base X - Fraction We know how to do that for the integer part and here we only talk about the fraction part inputVal is the

6、fraction part of a number/liux/courses/cda3100/inclassexamples/decimal-baseX-float.c/liux/courses/cda3100/inclassexamples/baseX-decimal-float.c1/12/2015 1:02:49 PMweek02-3.ppt9Floating Point Numbers Scientific notation for decimal numbers A number is represent

7、ed by a significand (or mantissa) and an integer exponent Where F is the significand, and E the exponent Here S represents the sign Examples include ESF10) 1(421000001. 0101415926. 31/12/2015 1:03:48 PMweek02-3.ppt10Normalized Number Normalized number A scientific notation is normalized if there is

8、a single non-zero digit to the left of the floating point For example, are normalized are not normalized9ten9ten103.15576or 100 . 18ten8ten1031.5576or 1010. 01/12/2015 1:08:02 PMweek02-3.ppt11Floating Points in Binary Normalized binary scientific notation For a fixed number of bits, we need to decid

9、e How many bits for the significand (or fraction) How many bits for the exponent There is a trade-off between precision and range More bits for significand increases precision while more bits for exponent increases the rangeyyyytwoxxxxxxxxxx2. 11/12/2015 1:08:16 PMweek02-3.ppt12IEEE 754 Floating Poi

10、nt Standard Single precision Represented by 32 bits Since the leading 1 bit in the significand in normalized binary numbers is always 1, it is not represented explicitly5/3/2022CDA310013Exponent If we represent exponents using twos complement, then it would not be intuitive as small numbers appear t

11、o be larger3130292827262524232221201918171615141312111098765432100 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 03130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 05/3/2022CDA310014Biased Notation The most negative expo

12、nent will be represented as 0000 and the most positive as 11111 That is, we need to subtract the bias from the corresponding unassigned value The value of an IEEE 754 single precision is)127Exponent(2)Fraction. 01 () 1(S313029282726252423222120191817161514131211109876543210sexponentfraction1 bit8 bi

13、ts23 bits5/3/2022CDA310015Example 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75 The normalized binary number will be 1.011122 = 1.01112(129-127) So the exponent is 129ten = 10000001As a hexadecimal number, the representation is 0 x40B80000 3130292827262524232221201918171615141312111098765432100 1 0 0 0 0 0

14、0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 05/3/2022CDA310016Example So the exponent is 123ten = 01111011As a hexadecimal number, the representation is 0 x3DCCCCCC 3130292827262524232221201918171615141312111098765432100 0 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 012712321001. 1

15、00110 . 01 . 0twotwoten5/3/2022CDA3100170.1 Caused Serious Losses5/3/2022CDA310018IEEE 754 Double Precision It uses 64 bits (two 32-bit words) 1 bit for the sign 11 bits for the exponent 52 bits for the fraction 1023 as the bias313029282726252423222120191817161514131211109876543210sExponentfraction1

16、 bit11 bits20 bitsFraction (continued)32 bits5/3/2022CDA310019Example (Double Precision) 101.11two= 22 + 20 + 2-1 + 2-2 = 5.75 The normalized binary number will be 1.011122 = 1.01112(1025-1023) So the exponent is 1025ten = 10000000001twoAs a hexadecimal number, the representation is 0 x4017 0000 000

17、0 00003130292827262524232221201918171615141312111098765432100 1 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 03130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 05/3/2022CDA310020Special CasesSingle precisionDouble precisi

18、onObject representedExponentFractionExponentFraction000000nonzero0nonzerodenormalized number1-254anything1-2046anythingfloating-point number255020470 infinity255nonzero2047nonzeroNaN (Not a number)In 2008, denormalized numbers are renamed to subnormal ones5/3/2022CDA310021Ranges for IEEE 754 Single

19、Precision Largest positive number Smallest positive number Floating-point number Denormalized number3130292827262524232221201918171615141312111098765432100 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 1 0 0 0 0 0 0

20、 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 03130292827262524232221201918171615141312111098765432100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11/12/2015 11:17:14 PMweek02-3.ppt22Ranges for IEEE 754 Single Precision Largest positive number Smallest positive number Floating-point number - norm

21、alized Denormalized number Overflow and underflow Overflow if the exponent is too large to be represented Underflow if the exponent is too small to be represented38104128)127254(23103.4028235516925440170418348438528859813402823466222)211 (38126)1271(10175494351. 122)0 . 01 (23(0 126)14945(0.02)221.4

22、012985 10(0 126)( 1)(00.Fraction)2S5/3/2022CDA310023Ranges for IEEE 754 Double Precision Largest positive number Smallest positive number Floating-point number Denormalized number52(0 1022)1074324(0.02)224.94065646 103081022)10231(102250738585. 222)0 . 01 (3089711024)10232046(52106231577976931348. 1

23、222)211 (0 1022)( 1)(00.Fraction)2S5/3/2022CDA310024Range for Intels 80-bit Format Intels IA-32 internally uses a 80-bit floating point (extended precision representation) It includes a sign bit, a 16-bit exponent, and 63-bit significant (64-bit if the implied 1 is also included) The bias is 32767 W

24、hat is the largest positive number? What is the smallest positive number?5/3/2022CDA310025Bit Fields in C C (C+ also) allows bit fields to be defined within words All the fields must fit within a single word Fields must be integral types Starts from the right-most bit31302928272625242322212019181716

25、1514131211109876543210sexponentfraction1 bit8 bits23 bits5/3/2022CDA310026Endianness Byte ordering How a multiple byte data stored in memory Endianness (from Gullivers Travels) Big endian significant byte of a multi-byte word is stored at the memory address e.g. Sun Sparc, PowerPC Little endian sign

26、ificant byte of a multi-byte word is stored at the memory address e.g. Intel x865/3/2022CDA310027Endianness - continued Note that the bit fields depend on the endianness of the machine313029282726252423222120191817161514131211109876543210sexponentfraction1 bit8 bits23 bitsBit field direction on litt

27、le endian machinesBit field direction on big endian machines5/3/2022CDA310028Bit Fields in C The formula to compute the decimal floating point value using the bit fields is Note that the prototype for pow is defined in and the function is defined in the math library (using lm to link the math librar

28、y)5/3/2022CDA310029Meaning of Bit Patterns What a bit pattern represents depends what it is for Example, the following bit pattern A twos complement integer An unsigned integer A single precision floating-point number A MIPS instruction3130292827262524232221201918171615141312111098765432101 0 1 0 1

29、1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 05/3/2022CDA310030Meaning of Bit Patterns What a bit pattern represents depends what it is for Example, the following bit pattern A twos complement integer An unsigned integer A single precision floating-point A MIPS instruction31302928272625242322

30、21201918171615141312111098765432101 0 1 0 1 1 0 1 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 05/3/2022CDA310031Stored Program Concept Programs consist of instructions and data Instructions are also represented as 0s and 1s Before a program runs, it will be loaded and stored in memory; it can be r

31、ead and written just like numbers A program is executed instruction by instruction These apply to all kinds of programs, operating systems, applications, games, and so on1/12/2015 10:56:39 PMweek02-3.ppt33GoogleEarth.exe1/12/2015 10:56:38 PMweek02-3.ppt34Linux Kernel1/12/2015 10:56:38 PMweek02-3.ppt

32、35Five Classic Components1/12/2015 10:56:37 PMweek02-3.ppt36Instruction Set Architectures An instruction set architecture specifies Instructions Registers Memory access Input/output An instruction set architecture provides an abstraction of the hardware implementation The hardware implementation dec

33、ides what and how instructions are implemented1/12/2015 10:56:37 PMweek02-3.ppt37Abstract View of MIPS Implementation1/12/2015 10:56:35 PMweek02-3.ppt38Instruction Execution Steps Instruction fetch step Fetch the instruction from memory and compute the address of the next sequential instruction Inst

34、ruction decode and register fetch step Decode the instruction and read registers Instruction execution Memory access / result Memory 1/12/2015 10:56:35 PMweek02-3.ppt39Instructions Note the operands for an arithmetic instruction must be from registers Reading from and storing to memory can be done using only specific instructions1/12/2015 10:56:34 PMweek02-3.ppt40Arithmetic Instruction Execution1/12/2015 10:56:34 PMweek02-3.ppt411/12/2015 10:56:24 PMweek02-3.ppt42Summary Now we know how to represent unsigned, signed, and floating points in computers Unsigned Signed using twos co

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論