第2章(4學(xué)時(shí)) 計(jì)算機(jī)的信息表示英文_第1頁
第2章(4學(xué)時(shí)) 計(jì)算機(jī)的信息表示英文_第2頁
第2章(4學(xué)時(shí)) 計(jì)算機(jī)的信息表示英文_第3頁
第2章(4學(xué)時(shí)) 計(jì)算機(jī)的信息表示英文_第4頁
第2章(4學(xué)時(shí)) 計(jì)算機(jī)的信息表示英文_第5頁
已閱讀5頁,還剩66頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

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(帶權(quán)的位置數(shù)制)Anumberisrepresentedbyanumberofdigitseachofwhichevaluatestoaprespecifiedvaluethesumofthevaluescontributedbyallthedigitsequalsthevalueofthenumber.Radix(基數(shù))weighted(權(quán))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(按權(quán)展開法:先寫成多項(xiàng)式,然后計(jì)算十進(jìn)制結(jié)果)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……h(huán)igh……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……h(huán)igh……low2、Conversionbetweennumbersof

differentrepresentationsexampleFractionalpart2)decimaltobinaryConvert(0.2)10tobinary

(0.2)10=[0.001100110011….]2……h(huán)igh……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(符號(hào)數(shù)值表示,原碼)Two’scomplementrepresentation(二進(jìn)制補(bǔ)碼)One’scomplementrepresentation(二進(jìn)制反碼)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(補(bǔ)碼)999— 176 823

253

— 176

2.Two’scomplementrepresentation(補(bǔ)碼)

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(補(bǔ)碼)補(bǔ)碼的補(bǔ)充說明:

就象我們前面所演示給大家看的,補(bǔ)碼的發(fā)現(xiàn)其實(shí)是為了消滅減法。正數(shù)根本不需要什么補(bǔ)碼,補(bǔ)碼是一個(gè)減法的差,所以求一個(gè)數(shù)的補(bǔ)碼就是做一個(gè)減法。

2.Two’scomplementrepresentation(補(bǔ)碼)DecimalExample:

X1=+0.1011011

X2=-0.1011011

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

=1.01001012.Two’scomplementrepresentation(補(bǔ)碼)IntegerExample: X1=+01011011

X2=-01011011[X1]2‘scompl

=01011011[X2]2‘scompl

=

101001012.Two’scomplementrepresentation(補(bǔ)碼)Rangeofcomplementrepresentation:integer:-2n-1to2n-1-1decimal:-1

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

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

[X]sign-mag=11001001

[X]2’scompl=10110110+1=101101112.Two’scomplementrepresentation(補(bǔ)碼)Given[X]2’scompl,get[-X]2’scompl

(求機(jī)器負(fù)數(shù))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(補(bǔ)碼)exampleGiven[X]2’scompl,get[-X]2’scompl

(求機(jī)器負(fù)數(shù))oppositeallbitswithsign,add1Ex:X=+1001001(wordlengthN=8)

[X]2’scompl=01001001

[-X]2’scompl=101101112.Two’scomplementrepresentation(補(bǔ)碼)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)轉(zhuǎn)換(補(bǔ)充)格雷碼轉(zhuǎn)二進(jìn)制最高位不變,保留到最高位,再將異或的值和下一位相異或,結(jié)果保留到下一位,依次異或,直到最低位。01100100⊕⊕⊕11101011⊕⊕⊕格雷碼二進(jìn)制2.5Othercodesystems1.GrayCodes(unweightedcodesystem)轉(zhuǎn)換(補(bǔ)充)二進(jìn)制轉(zhuǎn)格雷碼保留自然二進(jìn)制碼的最高位作為格雷碼的最高位,而次高位格雷碼為二進(jìn)制碼的高位與次高位相異或,而格雷碼其余各位與次高位的求法相類似。01100101⊕⊕⊕11101001⊕⊕⊕格雷碼二進(jìn)制2.5Othercodesystems九連環(huán)的全部狀態(tài)

第0個(gè)狀態(tài): 000000000格雷碼:000000000二進(jìn)制數(shù):000000000

動(dòng)作P,狀態(tài)1: 100000000格雷碼:000000001二進(jìn)制數(shù):000000001

動(dòng)作Q,狀態(tài)2: 110000000格雷碼:000000011二進(jìn)制數(shù):000000010

動(dòng)作P,狀態(tài)3: 010000000格雷碼:000000010二進(jìn)制數(shù):000000011

動(dòng)作Q,狀態(tài)4: 011000000格雷碼:000000110二進(jìn)制數(shù):000000100

動(dòng)作P,狀態(tài)5: 111000000格雷碼:000000111二進(jìn)制數(shù):000000101

動(dòng)作Q,狀態(tài)6: 101000000格雷碼:000000101二進(jìn)制數(shù):000000110

動(dòng)作P,狀態(tài)7: 001000000格雷碼:000000100二進(jìn)制數(shù):000000111

動(dòng)作Q,狀態(tài)8: 001100000格雷碼:000001100二進(jìn)制數(shù):000001000

動(dòng)作P,狀態(tài)9: 101100000格雷碼:000001101二進(jìn)制數(shù):000001001

動(dòng)作Q,狀態(tài)10: 111100000格雷碼:000001111二進(jìn)制數(shù):000001010

動(dòng)作P,狀態(tài)11: 011100000格雷碼:000001110二進(jìn)制數(shù):000001011

動(dòng)作Q,狀態(tài)12: 010100000格雷碼:000001010二進(jìn)制數(shù):000001100

動(dòng)作P,狀態(tài)13: 110100000格雷碼:000001011二進(jìn)制數(shù):000001101

動(dòng)作Q,狀態(tài)14: 100100000格雷碼:000001001二進(jìn)制數(shù):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等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(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)論