计算机组成与结构:第二部分-程序和数据的机器级表达 03-信息存储_第1页
计算机组成与结构:第二部分-程序和数据的机器级表达 03-信息存储_第2页
计算机组成与结构:第二部分-程序和数据的机器级表达 03-信息存储_第3页
计算机组成与结构:第二部分-程序和数据的机器级表达 03-信息存储_第4页
计算机组成与结构:第二部分-程序和数据的机器级表达 03-信息存储_第5页
已阅读5页,还剩8页未读 继续免费阅读

下载本文档

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

文档简介

第2章信息的表示与处理

——信息存储

计算机组成与结构

2016年4月主讲教师Today:Information

StorageRepresentationsinmemory,pointers,stringsByte-OrientedMemoryOrganizationProgramsrefertodatabyaddressConceptually,envisionitasaverylargearrayofbytesInreality,it’snot,butcanthinkofitthatwayAnaddressislikeanindexintothatarrayand,apointervariablestoresanaddressNote:systemprovidesprivateaddressspacestoeach“process”ThinkofaprocessasaprogrambeingexecutedSo,aprogramcanclobberitsowndata,butnotthatofothers•••00•••0FF•••FMachineWordsAnygivencomputerhasa“WordSize”Nominalsizeofinteger-valueddataandofaddressesMostcurrentmachinesuse32bits(4bytes)aswordsizeLimitsaddressesto4GB(232bytes)Becomingtoosmallformemory-intensiveapplicationsleadingtoemergenceofcomputerswith64-bitwordsizeMachinesstillsupportmultipledataformatsFractionsormultiplesofwordsizeAlwaysintegralnumberofbytesWord-OrientedMemoryOrganizationAddressesSpecifyByteLocationsAddressoffirstbyteinwordAddressesofsuccessivewordsdifferby4(32-bit)or8(64-bit)00000001000200030004000500060007000800090010001132-bitWordsBytesAddr.001200130014001564-bitWordsAddr=??Addr=??Addr=??Addr=??Addr=??Addr=??000000040008001200000008Forotherdatarepresentationstoo…CDataTypeTypical32-bitIntelIA32x86-64char111short222int444long448longlong888float444double888longdouble810/1210/16pointer448ByteOrderingSo,howarethebyteswithinamulti-bytewordorderedinmemory?ConventionsBigEndian:Sun,PPCMac,InternetLeastsignificantbytehashighestaddressLittleEndian:x86LeastsignificantbytehaslowestaddressByteOrderingExampleExampleVariablexhas4-bytevalueof0x01234567Addressgivenby&xis0x1000x1000x1010x1020x103012345670x1000x1010x1020x10367452301BigEndianLittleEndian0123456767452301RepresentingIntegersDecimal: 15213Binary:

0011101101101101Hex:

3B6D6D3B0000IA32,x86-643B6D0000SunintA=15213;93C4FFFFIA32,x86-64C493FFFFSunTwo’scomplementrepresentationintB=-15213;longintC=15213;000000006D3B0000x86-643B6D0000Sun6D3B0000IA32ExaminingDataRepresentationsCodetoPrintByteRepresentationofDataCastingpointertounsignedchar*allowstreatmentasabytearrayPrintfdirectives:%p: Printpointer%x: PrintHexadecimaltypedefunsignedchar*pointer;voidshow_bytes(pointerstart,intlen){inti;for(i=0;i<len;i++)printf(”%p\t0x%.2x\n",start+i,start[i]);printf("\n");}show_bytesExecutionExampleinta=15213;printf("inta=15213;\n");show_bytes((pointer)&a,sizeof(int));Result(Linux):inta=15213;0x11ffffcb8 0x6d0x11ffffcb9 0x3b0x11ffffcba 0x000x11ffffcbb 0x00RepresentingPointersDifferentcompilers&machinesassigndifferentlocationstoobjectsintB=-15213;int*P=&B;x86-64SunIA32EFFFFB2CD4F8FFBF0C89ECFFFF7F0000charS[6]="18243";RepresentingStringsStringsinCRepresentedbyarrayofcharactersEachcharacterencodedinASCIIformatStandard7-bitencodingofcharactersetCharacter“0”hascode0x30

温馨提示

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

评论

0/150

提交评论