正在加载图片...
A-10 Appendix A Assemblers,Linkers,and the SPIM Simulator To compound the problem,longer programs are more difficult to read and understand and they contain more bugs.Assembly language exacerbates the prob- lem because of its complete lack of structure.Common programming idioms,such as if-then statements and loops,must be built from branches and jumps.The result- ing programs are hard to read because the reader must reconstruct every higher- level construct from its pieces and each instance of a statement may be slightly dif- ferent.For example,look at Figure A.1.4 and answer these questions:What type of loop is used?What are its lower and upper bounds? Elaboration:Compilers can produce machine language directly instead of relying on an assembler.These compilers typically execute much faster than those that invoke an assembler as part of compilation.However,a compiler that generates machine lan- guage must perform many tasks that an assembler normally handles,such as resolving addresses and encoding instructions as binary numbers.The trade-off is between com- pilation speed and compiler simplicity. Elaboration:Despite these considerations,some embedded applications are writ- ten in a high-level language.Many of these applications are large and complex pro- grams that must be extremely reliable.Assembly language programs are longer and more difficult to write and read than high-level language programs.This greatly increases the cost of writing an assembly language program and makes it extremely dif- ficult to verify the correctness of this type of program.In fact,these considerations led the Department of Defense,which pays for many complex embedded systems,to develop Ada,a new high-level language for writing embedded systems. A.2 Assemblers An assembler translates a file of assembly language statements into a file of binary external label Also called glo- machine instructions and binary data.The translation process has two major parts. bal label.A label referring to an The first step is to find memory locations with labels so the relationship between object that can be referenced symbolic names and addresses is known when instructions are translated.The sec- from files other than the one in ond step is to translate each assembly statement by combining the numeric equiva- which it is defined. lents of opcodes,register specifiers,and labels into a legal instruction.As shown in local label A label referring to Figure A.1.1,the assembler produces an output file,called an object file,which con- an object that can be used only tains the machine instructions,data,and bookkeeping information. within the file in which it is An object file typically cannot be executed because it references procedures or defined. data in other files.A label is external (also called global)if the labeled object canA-10 Appendix A Assemblers, Linkers, and the SPIM Simulator To compound the problem, longer programs are more difficult to read and understand and they contain more bugs. Assembly language exacerbates the prob￾lem because of its complete lack of structure. Common programming idioms, such as if-then statements and loops, must be built from branches and jumps. The result￾ing programs are hard to read because the reader must reconstruct every higher￾level construct from its pieces and each instance of a statement may be slightly dif￾ferent. For example, look at Figure A.1.4 and answer these questions: What type of loop is used? What are its lower and upper bounds? Elaboration: Compilers can produce machine language directly instead of relying on an assembler. These compilers typically execute much faster than those that invoke an assembler as part of compilation. However, a compiler that generates machine lan￾guage must perform many tasks that an assembler normally handles, such as resolving addresses and encoding instructions as binary numbers. The trade-off is between com￾pilation speed and compiler simplicity. Elaboration: Despite these considerations, some embedded applications are writ￾ten in a high-level language. Many of these applications are large and complex pro￾grams that must be extremely reliable. Assembly language programs are longer and more difficult to write and read than high-level language programs. This greatly increases the cost of writing an assembly language program and makes it extremely dif- ficult to verify the correctness of this type of program. In fact, these considerations led the Department of Defense, which pays for many complex embedded systems, to develop Ada, a new high-level language for writing embedded systems. An assembler translates a file of assembly language statements into a file of binary machine instructions and binary data. The translation process has two major parts. The first step is to find memory locations with labels so the relationship between symbolic names and addresses is known when instructions are translated. The sec￾ond step is to translate each assembly statement by combining the numeric equiva￾lents of opcodes, register specifiers, and labels into a legal instruction. As shown in Figure A.1.1, the assembler produces an output file, called an object file, which con￾tains the machine instructions, data, and bookkeeping information. An object file typically cannot be executed because it references procedures or data in other files. A label is external (also called global) if the labeled object can A.2 Assemblers A.2 external label Also called glo￾bal label. A label referring to an object that can be referenced from files other than the one in which it is defined. local label A label referring to an object that can be used only within the file in which it is defined
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有