(Machine Structures)计算机结构与组成002_第1页
(Machine Structures)计算机结构与组成002_第2页
(Machine Structures)计算机结构与组成002_第3页
(Machine Structures)计算机结构与组成002_第4页
(Machine Structures)计算机结构与组成002_第5页
已阅读5页,还剩27页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Lecturer SOE Dan Garcia/ddgarcia/cs61c CS61C : Machine StructuresLecture #2 Number Representation2007-01-19There is one handout today at the front and back of the room!Great book The Universal Historyof Numbersby Georges IfrahGreat DeCal courses I supervise (2 units)UCBUGGUC Berkeley Undergraduate G

2、raphics GroupThursdays 5:30-7:30pm in 310 SodaLearn to create a short 3D animationNo prereqs (but they might have too many students, so admission not guaranteed)MS-DOS XMacintosh Software Developers for OS XThursdays 5-7pm in 320 SodaLearn to program the Macintosh and write an awesome GUI applicatio

3、nNo prereqs (other than interest)ReviewContinued rapid improvement in computing2Xevery 2.0 years in memory size; every 1.5 years in processor speed; every 1.0 year in disk capacity; Moores Law enables processor(2X transistors/chip 1.5 yrs)5 classic components of all computers Control Datapath Memory

4、 Input OutputProcessorMy goal as an instructorTo make your experience in CS61C as enjoyable & informative as possibleHumor, enthusiasm, graphics & technology-in-the-news in lectureFun, challenging projects & HWPro-student policies (exam clobbering)To maintain Cal & EECS standards of excellenceYour p

5、rojects & exams will be just as rigorous as every year. Overall : B- avgTo be an HKN “7.0” manI know I speak fast when I get excited about material. Im told every semester. Help me slow down when I go toooo fast.Please give me feedback so I improve! Why am I not 7.0 for you? I will listen!Putting it

6、 all in perspective“If the automobile had followed the same development cycle as the computer,a Rolls-Royce would today cost $100,get a million miles per gallon, and explode once a year, killing everyone inside.” Robert X. CringelyDecimal Numbers: Base 10Digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9Example:3

7、271 = (3x103) + (2x102) + (7x101) + (1x100)Numbers: positional notationNumber Base B B symbols per digit:Base 10 (Decimal):0, 1, 2, 3, 4, 5, 6, 7, 8, 9Base 2 (Binary):0, 1Number representation: d31d30 . d1d0 is a 32 digit numbervalue = d31 B31 + d30 B30 + . + d1 B1 + d0 B0Binary:0,1 (In binary digit

8、s called “bits”)0b11010 = 124 + 123 + 022 + 121 + 020 = 16 + 8 + 2= 26Here 5 digit binary # turns into a 2 digit decimal #Can we find a base that converts to binary easily?#s often written0bHexadecimal Numbers: Base 16Hexadecimal: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, FNormal digits + 6 more

9、from the alphabetIn C, written as 0 x (e.g., 0 xFAB5)Conversion: BinaryHex1 hex digit represents 16 decimal values4 binary digits represent 16 decimal values1 hex digit replaces 4 binary digitsOne hex digit is a “nibble”. Two is a “byte”Example:1010 1100 0011 (binary) = 0 x_ ?Decimal vs. Hexadecimal

10、 vs. BinaryExamples:1010 1100 0011 (binary) = 0 xAC310111 (binary) = 0001 0111 (binary) = 0 x170 x3F9 = 11 1111 1001 (binary)How do we convert between hex and Decimal?00 00000011000102 20010033001104 40100055010106 60110077011108 81000099100110 A101011B101112 C110013D110114 E111015F1111MEMORIZE!Exam

11、ples:1010 1100 0011 (binary) = 0 xAC310111 (binary) = 0001 0111 (binary) = 0 x170 x3F9 = 11 1111 1001 (binary)How do we convert between hex and Decimal?Kilo, Mega, Giga, Tera, Peta, Exa, Zetta, YottaCommon use prefixes (all SI, except K = k in SI)Confusing! Common usage of “kilobyte” means 1024 byte

12、s, but the “correct” SI value is 1000 bytesHard Disk manufacturers & Telecommunications are the only computing groups that use SI factors, so what is advertised as a 30GB drive will actually only hold about 28 x 230 bytes, and a 1Mbit/s connection transfers 106 bps.NameAbbrFactorSI sizeKiloK210 = 1,

13、024103 = 1,000MegaM220 = 1,048,576106 = 1,000,000GigaG230 = 1,073,741,824109 = 1,000,000,000TeraT240 = 1,099,511,627,7761012 = 1,000,000,000,000PetaP250 = 1,125,899,906,842,6241015 = 1,000,000,000,000,000ExaE260 = 1,152,921,504,606,846,9761018 = 1,000,000,000,000,000,000ZettaZ270 = 1,180,591,620,717

14、,411,303,4241021 = 1,000,000,000,000,000,000,000YottaY280 = 1,208,925,819,614,629,174,706,1761024 = 1,000,000,000,000,000,000,000,000/cuu/Units/binary.htmlkibi, mebi, gibi, tebi, pebi, exbi, zebi, yobiNew IEC Standard Prefixes only to exbi officiallyInternational Electrotechnical Commission (IEC) in

15、 1999 introduced these to specify binary quantities. Names come from shortened versions of the original SI prefixes (same pronunciation) and bi is short for “binary”, but pronounced “bee” :-(Now SI prefixes only have their base-10 meaning and never have a base-2 meaning.NameAbbrFactorkibiKi210 = 1,0

16、24mebiMi220 = 1,048,576gibiGi230 = 1,073,741,824tebiTi240 = 1,099,511,627,776pebiPi250 = 1,125,899,906,842,624exbiEi260 = 1,152,921,504,606,846,976zebiZi270 = 1,180,591,620,717,411,303,424yobiYi280 = 1,208,925,819,614,629,174,706,176/wiki/Binary_prefixAs of thiswriting, thisproposal hasyet to gainwi

17、despreaduseWhat is 234? How many bits addresses (I.e., whats ceil log2 = lg of) 2.5 TiB?Answer! 2XY meansX=0 -X=1 kibi 103X=2 mebi 106X=3 gibi 109X=4 tebi 1012X=5 pebi 1015X=6 exbi 1018X=7 zebi 1021X=8 yobi 1024The way to remember #sY=0 1Y=1 2Y=2 4Y=3 8Y=4 16Y=5 32Y=6 64Y=7 128Y=8 256Y=9 512MEMORIZE

18、!What to do with representations of numbers?Just what we do with numbers!Add themSubtract themMultiply themDivide themCompare themExample: 10 + 7 = 17so simple to add in binary that we can build circuits to do it!subtraction just as you would in decimalComparison: How do you tell if X Y ? 1 0 1 0+ 0

19、 1 1 1-1 0 0 0 111Which base do we use?Decimal: great for humans, especially when doing arithmeticHex: if human looking at long strings of binary numbers, its much easier to convert to hex and look 4 bits/symbolTerrible for arithmetic on paperBinary: what computers use; you will learn how computers

20、do +, -, *, /To a computer, numbers always binaryRegardless of how number is written:32ten = 3210 = 0 x20 = 1000002 = 0b100000Use subscripts “ten”, “hex”, “two” in book, slides when might be confusingBIG IDEA: Bits can represent anything!Characters?26 letters 5 bits (25 = 32)upper/lower case + punct

21、uation 7 bits (in 8) (“ASCII”)standard code to cover all the worlds languages 8,16,32 bits (“Unicode”)Logical values?0 False, 1 Truecolors ? Ex:locations / addresses? commands?MEMORIZE: N bits at most 2N thingsRed (00)Green (01)Blue (11)How to Represent Negative Numbers?So far, unsigned numbersObvio

22、us solution: define leftmost bit to be sign! 0 +, 1 Rest of bits can be numerical value of numberRepresentation called sign and magnitude(原码)MIPS uses 32-bit integers. +1ten would be:0000 0000 0000 0000 0000 0000 0000 0001And 1ten in sign and magnitude would be:1000 0000 0000 0000 0000 0000 0000 000

23、1Shortcomings of sign and magnitude?Arithmetic circuit complicatedSpecial steps depending whether signs are the same or notAlso, two zeros 0 x00000000 = +0ten 0 x80000000 = 0ten What would two 0s mean for programming?Therefore sign and magnitude abandonedAdministriviaUpcoming lecturesNext three lect

24、ures: Introduction to CLab overcrowdingRemember, you can go to ANY discussion (none, or one that doesnt match with lab, or even more than one if you want)Overcrowded labs - consider finishing at home and getting checkoffs in lab, or bringing laptop to labHWHW0 due in discussion next weekHW1 due this

25、 Wed 23:59 PSTHW2 due following Wed 23:59 PSTReadingK&R Chapters 1-6 (lots, get started now!); 1st quiz due Sun!Soda locks doors 6:30pm & on weekendsLook at class website, newsgroup often!/cs61c/ucb.class.cs61cAnother try: complement the bitsExample: 710 = 001112 710 = 110002Called Ones Complement(反

26、码)Note: positive numbers have leading 0s, negative numbers have leadings 1s.000000000101111.111111111010000.What is -00000 ? Answer: 11111How many positive numbers in N bits?How many negative numbers?Shortcomings of Ones complement?Arithmetic still a somewhat complicated.Still two zeros 0 x00000000

27、= +0ten 0 xFFFFFFFF = -0ten Although used for awhile on some computer products, ones complement was eventually abandoned because another solution was better.Standard Negative Number RepresentationWhat is result for unsigned numbers if tried to subtract large number from a small one?Would try to borr

28、ow from string of leading 0s, so result would have a string of leading 1s3 - 4 000011 000100 = 111111With no obvious better alternative, pick representation that made the hardware simpleAs with sign and magnitude, leading 0s positive, leading 1s negative000000.xxx is 0, 111111.xxx is Y (if signed)X Y (if unsigned)An encoding for Babylonians could have 2N non-negative numbers w/N bits! ABC0: FFF1: FFT2: FTF3: FTT4: TFF5: TFT6: TTF7: TTTNumber summary.We represent “things” in compute

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论