第3章程序的机器级表示——基本计算机组成与结构2016年4月主讲教师赵欢******@:MachineProgrammingI:BasicsHistoryofIntelprocessorsandarchitecturesC,assembly,machinecodeAssemblyBasics:Registers,operands,moveaddressingmode,putation*ArithmeticoperationsIntrotox86-64Intelx86Evolution:MilestonesName Date Transistors MHz8086 1978 29K 5-10First16-&DOS1MBaddressspace386 1985 275K 16-33First32bitprocessor,referredtoasIA32Added“flataddressing”,CapableofrunningUnixPentium4F 2004 125M 2800-3800First64-bitprocessor,referredtoasx86-64Core22006291M1060-3500Firstmulti-coreIntelprocessorCorei7 2008 731M 1700-3900Fourcores(oursharkmachines)-3700On-chipGPUOurCoverageIA32Thetraditionalx86x86-64/—--64,othersonIA32Today:MachineProgrammingI:BasicsHistoryofIntelprocessorsandarchitecturesC,assembly,machinecodeAssemblyBasics:Registers,operands,moveaddressingmode,putationArithmeticoperationsIntrotox86-64CPUAssemblyProgrammer’sViewProgrammer-VisibleStatePC:ProgramcounterAddressofnextinstructionCalled“EIP”(IA32)or“RIP”(x86-64)piler(gcc-S)Assembler(gccoras)Linker(gccorld)Cprogram()Asmprogram()Objectprogram()Executableprogram(p)Staticlibraries(.a):gcc–-opUsebasicoptimizations(-O1)[options][filenames]其中options就是编译器所需要的参数,filenames给出相关的文件名称-c,只编译,不链接为可执行。-o,确定输出文件的名称。如果不给出这个选项,。-s,产生汇编代码。-O1,对程序进行第一级优化编译、链接。-O2,比-O1更好的优化编译、链接,当然整个编译、链接过程会更慢。等等参考:阅读:课程网站推荐阅读资料“GCC”odeintsum(intx,inty){intt=x+y;returnt;}GeneratedIA32Assemblysum: pushl%ebp movl%esp,%ebp movl12(%ebp),%eax addl8(%ebp),%eax popl%ebp –O1-“leave”odeAddtwosignedintegersAssemblyAdd24-byteintegers“Long”parlanceSameinstructionwhethersignedorunsignedOperands:x: Register %eaxy: Memory M[%ebp+8]t: Register %eaxReturnfunctionvaluein%eaxObjectCode3-byteinstr
计算机组成与结构05-程序的机器级表示:基本 来自淘豆网www.taodocs.com转载请标明出处.