第2章(4学时) 计算机的信息表示英文_第1页
第2章(4学时) 计算机的信息表示英文_第2页
第2章(4学时) 计算机的信息表示英文_第3页
第2章(4学时) 计算机的信息表示英文_第4页
第2章(4学时) 计算机的信息表示英文_第5页
已阅读5页,还剩66页未读 继续免费阅读

下载本文档

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

文档简介

ComputerOrganizationChapter2TherepresentationofinformationinacomputerChapter2Therepresentationof

informationinacomputer2.1Datetypesrepresentinginformationinacomputer2.2Representationoffixed-pointunsignednumbers2.3Representationoffixed-pointsignednumbers2.4Binaryaddition/subtraction2.5OthercodesystemsChapter2Therepresentationof

informationinacomputerDatatypesinacomputersystem:file,graph,table,tree,array,queue,linkedlist,stack,vector,string,real,integer,Boolean,charThischaptermakesnoattempttodiscusstherepresentationsofallkindsofinformation.Itprovidesabasicintroductiontorepresentinginformation.DatatypeDatastructureDatarepresentationMostlyused,simple,easy

implementedbyhardwareDesignedforsystemsoftware,applicationoriented,relationshipbetweenlogicandphysicalstructure.Chapter2Therepresentationof

informationinacomputerPrinciplestodecidewhichdatatypesareimplementedbydatarepresentation:1.Reducetherunningtimeofprogram2.ReducethecommunicationcostbetweenCPUandmemory3.UniversalityandUtilization

Chapter2Therepresentationof

informationinacomputer2.1Datatypesrepresentinginformation

inacomputerBinaryvariablesandbinarycodesserveasthebasisforrepresentinginformationInordertorepresentdifferenttypesofinformation,weneedtoapplydifferentmethodsandsystemsofrepresentationutilizingbinarydigits.UnsignednumbersSignednumbersBitstringFix-PointNumberFloating-PointNumberUnsignednumber:arecreateddirectlyasordinarybinarycodesOperationcodesintheOPcodefieldRegisternumbersinaddressfieldMemoryaddresscounterTime,clockfrequency2.1Datatypesrepresentinginformation

inacomputerSignednumberNumericalandengineeringcomputationMostarithmeticoperationsintheinstructionsethandlesignedintegersorfloating-pointnumbersastheiroperands.bitstring(hasanevenwiderapplication)logicoperationsintheinstructionsetDenotesymbolssuchascharactersIncontrolunitofacomputer,forexample,instatuswords,taggeddata,andcontrolcodes.2.1Datatypesrepresentinginformation

inacomputerFix-PointNumberPointmeanstheDecimalpointinbinary.Fix-pointmeansthepositionof

Decimalpointisfixed.Itishidden。(不占位)

consistsoffix-pointdecimalandfix-pointinteger

signbit

Numericalpart

Positionofdicemalpoint

signbit

Numericalpart

F-pintegerF-pdecimal2.1Datatypesrepresentinginformation

inacomputer2.2representationof

fixed-pointunsignednumbersWeightedpositionalnumbersystem(带权的位置数制)Anumberisrepresentedbyanumberofdigitseachofwhichevaluatestoaprespecifiedvaluethesumofthevaluescontributedbyallthedigitsequalsthevalueofthenumber.Radix(基数)weighted(权)decimalsystembinarysystem,octalsystem,hexadecimalsystem1、Positionalnumbersystem1)(Decimal)Radix-10numbersystemuses10notationsforthedigits(0~9)weight:10iex:23.4123.45isexpressedas:123.45=1×102+2×101+3×100+4×10-1+5×10-24×10-13×1002×1011、Positionalnumbersystem2)(Binary)Radix-2numbersystemuses10notationsforthedigits(0,1)weight:2iex:101.11×2-11×200×211×223)(Hexadecimal)Radix-16numbersystemuses10notationsforthedigits(0~15)weight:16iex:2CA.E(2C7.1F)16isexpressedas:(2C7.1F)16=2×162+12×161+7×160+1

×16-1+15×16-21、Positionalnumbersystem14×16-110×16012×1612×1622、Conversionbetweennumbersof

differentrepresentations1)Conversionfrombinary(octal,hexadecimal)

todecimal(按权展开法:先写成多项式,然后计算十进制结果)N=dn-1dn-2•

•d1d0.d-1d-2

•d-m=dn-1×Rn-1+

dn-2×Rn-2+

+

d1×R1+d0×R0

(integerpart)

+

d-1×R-1+

d-2×R-2+•

+

d-m×R-m

(decimalpart)whererdenotestheradix

R=2;

R=8;

R=16;Convert(1101.01)2,(237)8,(10D)16totheirdecimalformat(1101.01)2=1×23+1×22+0×21+1×20+0×2-1+1×2-2

=8+4+1+0.25=13.25(237)8=2×82+3×81+7×80

=128+24+7=159(10D)16=1×162+13×160

=256+13=2692、Conversionbetweennumbersof

differentrepresentationsex2.12)decimaltobinaryTwosteps:Integerpart(除2取余法)Basedonrepeateddecimaldivisionby2Fractionalpart(乘2取整法)Basedonrepeateddecimalmultiplicationby22、Conversionbetweennumbersof

differentrepresentations2)decimaltobinaryConvert(327)10

tobinary2327Remainder216312811240122002100250221210201(327)10=(101000111)2……high……low2、Conversionbetweennumbersof

differentrepresentationsexampleIntegerpart2)decimaltobinaryConvert(0.8125)10

tobinary

0.8125×2=1.625 1 0.625×2=1.25 1 0.25×2=0.5 0 0.5×2=1 1

(0.8125)10=(0.1101)2……high……low2、Conversionbetweennumbersof

differentrepresentationsexampleFractionalpart2)decimaltobinaryConvert(0.2)10tobinary

(0.2)10=[0.001100110011….]2……high……low0.2×2=0.400.4×2=0.800.8×2=1.610.6×2=1.210.2×

2=0.400.4×2=0.800.8×2=1.610.6×2=1.212、Conversionbetweennumbersof

differentrepresentationsexampleFractionalpart3)others

binaryoctalbinary

hexadicimal

000

0 0000 0 10008 001

1 0001 1 10019 0102 0010 2 1010A 0113 0011 3 1011B 1004 0100 4 1100C 1015 0101 5 1101D 1106 0110 6 1110E 1117 0111 7 1111F2、Conversionbetweennumbersof

differentrepresentationsEx1:convertbinarytooctal(10110111.01101)2Ex2:convertoctaltobinary(123.46)8 =(001,010,011.100,110)2 =(1010011.10011)2octal:267.32binary:010,110,111.011,010binary:10,110,111.011,01=(267.32)82、Conversionbetweennumbersof

differentrepresentationsEx2.2Ex2.3Ex3:convertbinarytohexadecimal(110110111.01101)2Ex4:converthexadecimaltobinary(7AC.DE)16 =(0111,1010,1100.1101,1110)2

=(11110101100.1101111)2Hexa-:1B7.68binary:0001,1011,0111.0110,1000binary:1,1011,0111.0110,1=(1B7.68)162、Conversionbetweennumbersof

differentrepresentationsEx2.4Ex2.52.3representationof

fixed-pointsignednumbersForimplementationofarithmeticoperationsonsignednumbersinacomputer,weneedrules:Howtodenotethesignofanumber‘0’forpositive‘1’fornegativeAseparatesignbitisplacedatMSBpositionHowtorepresentthenumericalpartofanumberSign-Magnituderepresentation(符号数值表示,原码)Two’scomplementrepresentation(二进制补码)One’scomplementrepresentation(二进制反码)1.Sign-magnituderepresentation(原码)“0”

standfor+,“1”

standfor–decimalExample: X1=+0.1011011

X2=-0.1011011[X1]signmag

=0.1011011[X2]signmag

=1.10110111.Sign-magnituderepresentation(原码)“0”

standfor+,“1”

standfor–IntegerExample: X1=+01011011

X2=-01011011

[X1]sign-mag=01011011[X2]sign-mag

=11011011Rangeofdecimal[+0]=0.0000000;[-0]=1.0000000-(1-2-(n-1))~1-2-(n-1)Number:2n-

1Lengthofwordis8:range:-(1-2-7)~(1-2-7)

-127/128

127/128, amount:2550.11111111.11111111.Sign-magnituderepresentation(原码)Rangeofinteger[+0]=00000000;[-0]=10000000-(2n-1-1)~2n-1-1Number:2n-

Wordlength8:max127,min-127,number255Wordlength16:max32767,min-32767,number655351.Sign-magnituderepresentation(原码)Characterofsign-magnituderepresentationSimpletorepresent,easytomultiply/divideoperationHardtoadd/suboperationRequirescomparingthesignbitsoftwooperandsAnalternativeway,2’scomplementrepresentation1.Sign-magnituderepresentation(原码)origin:

transformthesubtractoperationtoadd:

253

— 176 ???2.Two’scomplementrepresentation(补码)999— 176 823

253

— 176

2.Two’scomplementrepresentation(补码)

253+ 999+1— 176—1000

253+ 823+1

—1000824iscomplementof-176withrespectto1000SubToadd253-176=77binaryformationof253

is11111101;binaryformationof176is10110000;

11111101 11111101- 10110000 + 11111111+1 - 10110000 Addthecomplement,Iftheresultisoverflow,thehighestpositionisdroppedautomatically.2.Two’scomplementrepresentation(补码)补码的补充说明:

就象我们前面所演示给大家看的,补码的发现其实是为了消灭减法。正数根本不需要什么补码,补码是一个减法的差,所以求一个数的补码就是做一个减法。

2.Two’scomplementrepresentation(补码)DecimalExample:

X1=+0.1011011

X2=-0.1011011

[X1]2‘scompl=0.1011011[X2]2‘scompl

=1.01001012.Two’scomplementrepresentation(补码)IntegerExample: X1=+01011011

X2=-01011011[X1]2‘scompl

=01011011[X2]2‘scompl

=

101001012.Two’scomplementrepresentation(补码)Rangeofcomplementrepresentation:integer:-2n-1to2n-1-1decimal:-1

to1-2-n-1Number:2nWordlength8:Range:-128~127

-1~127/1282.Two’scomplementrepresentation(补码)Conversionbetweensign-magand2’scomplpositive[X]2’scomple=[X]sign-magnegativeoppositeallbitexceptthesignbit,add1ex:X=-01001001

[X]sign-mag=11001001

[X]2’scompl=10110110+1=101101112.Two’scomplementrepresentation(补码)Given[X]2’scompl,get[-X]2’scompl

(求机器负数)Subtractiontoaddition[X]2’scompl

-[Y]2’scompl

=[X]2’scompl

+[-Y]2’scompl

X=(11)10Y=(5)10,wordlengthn=5,soluteX-Y=?Solute:[X]2’scompl-[Y]2’scompl

=[X]2’scompl

+[-Y]2’scompl

X=(11)10=(01011)2Y=(5)10=(00101)2-Y=(11011)2

[X]2’scompl-[Y]2’scompl

=01011+11011=100110=00110=(6)10

note:dropthehighestbit,whichexceedsthewordlength2.Two’scomplementrepresentation(补码)exampleGiven[X]2’scompl,get[-X]2’scompl

(求机器负数)oppositeallbitswithsign,add1Ex:X=+1001001(wordlengthN=8)

[X]2’scompl=01001001

[-X]2’scompl=101101112.Two’scomplementrepresentation(补码)positivethesign‘0’atMSBisattachedtothemagnitudeintheremainingn-1bits.Negativethesign‘1’atMSBisattachedtothe1’scomplofthemagnitudeintheremainingn-1bits.decimal:X1=+0.1011011,[X1]1’scompl=0.1011011X2=-0.1011011,[X2]1’scompl=1.0100100integer:X3=+1011011,[X3]1’scompl=01011011X4=-1011011,[X4]1’scompl

=10100100[+0]1’scompl

=00000000;[-0]1’scompl

=111111113.One’scomplementrepresentation(反码)example2-1、Givethesign-mag、1’scompl、2’scompl

representationofthefollownumber(wordlengthis8),whereMSBisthehighestbit(signbit),LSBisthelowestbit。Ifthenumberisdecimal,thedecimalpointisbehindtheMSB;ifthenumberisinteger,thenthedecimalpointisbehindtheLSB. (1)–35/64 (2)23/128 (3)–127 (4)–1(decimalrepresentation) (5)–1(integerrepresentation)2.4Fixed-pointaddition/subtractionSign-magnitudeadd/subCompare:signofA=signB?SamesignTest:AplusorminusB?differentsignTest:AplusorminusB?YesNo|A|+|B|,takesignofA+_Carryout=1Carryout=0overflowResultok|A|-|B|,takesignofA+Carryout=1ResultokCarryout=02’scompltheresult;Reversethesign_Fig2.4theflowchartofthealgorithmforsign-magnitudeadd/sub2.4Fixed-pointaddition/subtraction2’scomplementadd/subsignbitisalsoinvolvedincomputingIstheoperationdecidedbyopcode?Doestheresultneedamending?Howtotransformthesubtractiontoaddition??2’scomplementadd/sub①basicrules

[X+Y]2’scompl=[X]2’scompl+[Y]2’scompl

(1)

[X-

Y]2’scompl

=[X]2’scompl+[-Y]2’scompl

(2)(1):whenopcodeis“+”,addtwonumbersdirectly(2):whenopcodeis”-”,sub..—>add..

[Y]2’scompl

[–Y]2’scompl

:

Nomatter

Y2’scompl

ispositiveofnegative,oppositeallbits,andadd1onitsendbit.2.4Fixed-pointaddition/subtraction2’scomplementadd/sub②processOperandis2’scomplementformatinvolvingsignbitResultis2’scomplementformatsignbitindicatesthesignoftheresult[X]2’scompl

+[Y]2’scompl[X]

2’scompl

+[-Y]

2’scomplADDSUB2.4Fixed-pointaddition/subtractionOverflowjudgmentwhichsituationcausesoverflow?Overflow:resultexceedstherangeofrepresentation.Obviously,additionwithtwooppositesignandsubtractionwithtwosamesignwillnotcauseoverflow.Overflowmustbecaught.2.4Fixed-pointaddition/subtractionOverflowjudgmentAssumetwosignednumbers [A]2’scompl=[SaAn-2…

A1A0]2’scompl[B]2’scompl=[SbBn-2…

B1B0]2’scomplSA

A3A2A1A0SB

B3

B2B1B0SF

F3F2F1F0CCF2.4Fixed-pointaddition/subtractioncorrect0001100010(1)A=3B=23+2:00101(2)A=10B=710+7:010100011110001underflowcorrectoverflowcorrectcorrect(3)A=-3B=-2-3+(-2):110111110111110(4)A=-10B=-7-10+(-7):011111011011001(5)A=6B=-46+(-4):000100011011100(6)A=-6B=4-6+4:111101101000100Overflowjudgment2.4Fixed-pointaddition/subtraction(2)A=10B=710+7:01010

0011110001(4)A=-10B=-7-10+(-7):011111011011001①Judgmentlogicbyhardware1(SA、SBandSf)OF=SASBSfSASfSB②Judgmentlogicbyhardware2

(Cf

andC)Overflowjudgment2.4Fixed-pointaddition/subtractioncorrect0001100010(1)A=3B=23+2:00101(2)A=10B=710+7:010100011110001overflowcorrectunderflowcorrectcorrect(3)A=-3B=-2-3+(-2):110111110111110(4)A=-10B=-7-10+(-7):011111011011001(5)A=6B=-46+(-4):000100011011100(6)A=-6B=4-6+4:111101101000100Cf=0C=0Cf=0C=1Cf=1C=1Cf=1C=0Cf=1C=1Cf=0C=01111112.4Fixed-pointaddition/subtractionOverflowjudgmentOF=SASBSfSASfSBOF=CfC③Judgmentlogicbyhardware3

(doublesignbit)2.4Fixed-pointaddition/subtractionOverflowjudgment①Judgmentlogicbyhardware1(SA、SBandSf)②Judgmentlogicbyhardware2

(Cf

andC)(1)3+2:correct000011000010000101(2)10+7:001010000111010001overflowcorrectunderflowcorrectcorrect(3)-3+(-2):110111111101111110(4)-10+(-7):101111110110111001(5)6+(-4):000010000110111100(6)-6+4:111110111010000100FirstSf1SecondSf22.4Fixed-pointaddition/subtractionOverflowjudgmentOF=SASBSfSASfSBOF=CfCOF=Sf1Sf22.4Fixed-pointaddition/subtractionOverflowjudgment①Judgmentlogicbyhardware1(SA、SBandSf)②Judgmentlogicbyhardware2

(Cf

andC)③Judgmentlogicbyhardware3

(doublesignbit)2.5Othercodesystems1.GrayCodes(unweightedcodesystem)b3b2b1b0comments0000000121axis0011001022axis0110011121axis0101010023axis1100110121axis1111111022axis1010101121axis100110002.5Othercodesystems1.GrayCodes(unweightedcodesystem)Properties:Anytwosuccessivecodeshaveonlyonebitchanging.Generatesmoothlyvaryingcontrolsignals,analog-digitalconversionsignals,etc.Thecodeisreflective.DeriveanysubsetoftheGraycode.Removing6codesbetween0110and1110Removing4codesbetween0001and01012.5Othercodesystems1.GrayCodes(unweightedcodesystem)b3b2b1b0comments0000000121axis0011001022axis0110011121axis0101010023axis1100110121axis1111111022axis1010101121axis100110002.5Othercodesystems1.GrayCodes(unweightedcodesystem)b3b2b1b0comments0000000121axis0011001022axis0110011121axis0101010023axis1100110121axis1111111022axis1010101121axis100110002.5Othercodesystems1.GrayCodes(unweightedcodesystem)转换(补充)格雷码转二进制最高位不变,保留到最高位,再将异或的值和下一位相异或,结果保留到下一位,依次异或,直到最低位。01100100⊕⊕⊕11101011⊕⊕⊕格雷码二进制2.5Othercodesystems1.GrayCodes(unweightedcodesystem)转换(补充)二进制转格雷码保留自然二进制码的最高位作为格雷码的最高位,而次高位格雷码为二进制码的高位与次高位相异或,而格雷码其余各位与次高位的求法相类似。01100101⊕⊕⊕11101001⊕⊕⊕格雷码二进制2.5Othercodesystems九连环的全部状态

第0个状态: 000000000格雷码:000000000二进制数:000000000

动作P,状态1: 100000000格雷码:000000001二进制数:000000001

动作Q,状态2: 110000000格雷码:000000011二进制数:000000010

动作P,状态3: 010000000格雷码:000000010二进制数:000000011

动作Q,状态4: 011000000格雷码:000000110二进制数:000000100

动作P,状态5: 111000000格雷码:000000111二进制数:000000101

动作Q,状态6: 101000000格雷码:000000101二进制数:000000110

动作P,状态7: 001000000格雷码:000000100二进制数:000000111

动作Q,状态8: 001100000格雷码:000001100二进制数:000001000

动作P,状态9: 101100000格雷码:000001101二进制数:000001001

动作Q,状态10: 111100000格雷码:000001111二进制数:000001010

动作P,状态11: 011100000格雷码:000001110二进制数:000001011

动作Q,状态12: 010100000格雷码:000001010二进制数:000001100

动作P,状态13: 110100000格雷码:000001011二进制数:000001101

动作Q,状态14: 100100000格雷码:000001001二进制数:0000011102.5Othercodesystems2.Decimalcodes(1)Itisaweightedcodewiththesameweightsassignedtoitsfourbitsasthoseassignedtobinarynumbers.Binary-coded-decimal(BCD)codeisalsocalled8421codeValue:N=8d3+4d2+2d1+1d0 Forexample:BCDcodeof

(63.29)10is:01100011.001010012.5Othercodesystems2.DecimalcodesThealgorithmofone-digitBCDaddition:AddtwoBCDdigitsusingbinaryarithmetic;BCDadditionneedscorrection,add(0110)2;result>9【1001】createacarryElsenocorrectionoftheresultisnecessarysavethecarrygeneratedduringeitheroneofthetwoadditiontimes2.DecimalcodesExample:① 1+8=90001+10001001Nocorrection② 4+9=130100+1001

1101+0110correction10011carry③ 9+7=161001+011110000+0110correction10110carry2.5Othercodesystems2.5Othercodesystems2.DecimalcodesThealgorithmofone-digitBCDsubtraction:In10’scomplementrepresentationCanbereplacedbyBCDadditionSpecialhardwareisneededfortransformingaBCDdigittoits9’scomplement2.5Othercodesystems2.DecimalcodesSigneddecimalnumberscanberepresented:Sign-magnitude10’scomplement9’scomplementThesigndigitcanberepresentedinvariousways:E.g.selectingthenotationofthesignfromtheremaining4-bitcodesnotusedbydigits0to91010,1100,1110forpositiveand1011,1101,1111fornegative2.5

温馨提示

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

评论

0/150

提交评论