正在加载图片...
A-8 Appendix A Assemblers,Linkers,and the SPIM Simulator #include <stdio.h> int main (int argc.char *argv[]) int i: int sum 0: for (i 0:i <100:ii 1)sum sum +ii: printf ("The sum from 0 .100 is %d\n",sum): FIGURE A.1.5 The routine written in the C programming language. High-level language program Program Compiler Linker Computer Assembly language program FIGURE A.1.6 Assembly language either is written by a programmer or is the output of a compiler. tainty about the time cost of operations,programmers may find it difficult to ensure that a high-level language program responds within a definite time inter- val-say,1 millisecond after a sensor detects that a tire is skidding.An assembly language programmer,on the other hand,has tight control over which instruc- tions execute.In addition,in embedded applications,reducing a program's size, so that it fits in fewer memory chips,reduces the cost of the embedded computer. A hybrid approach,in which most of a program is written in a high-level lan- guage and time-critical sections are written in assembly language,builds on the strengths of both languages.Programs typically spend most of their time execut- ing a small fraction of the program's source code.This observation is just the principle of locality that underlies caches(see Section 7.2 in Chapter 7). Program profiling measures where a program spends its time and can find the time-critical parts of a program.In many cases,this portion of the program can be made faster with better data structures or algorithms.Sometimes,however,sig- nificant performance improvements only come from recoding a critical portion of a program in assembly language.A-8 Appendix A Assemblers, Linkers, and the SPIM Simulator tainty about the time cost of operations, programmers may find it difficult to ensure that a high-level language program responds within a definite time inter￾val—say, 1 millisecond after a sensor detects that a tire is skidding. An assembly language programmer, on the other hand, has tight control over which instruc￾tions execute. In addition, in embedded applications, reducing a program’s size, so that it fits in fewer memory chips, reduces the cost of the embedded computer. A hybrid approach, in which most of a program is written in a high-level lan￾guage and time-critical sections are written in assembly language, builds on the strengths of both languages. Programs typically spend most of their time execut￾ing a small fraction of the program’s source code. This observation is just the principle of locality that underlies caches (see Section 7.2 in Chapter 7). Program profiling measures where a program spends its time and can find the time-critical parts of a program. In many cases, this portion of the program can be made faster with better data structures or algorithms. Sometimes, however, sig￾nificant performance improvements only come from recoding a critical portion of a program in assembly language. #include <stdio.h> int main (int argc, char *argv[]) { int i; int sum = 0; for (i = 0; i <= 100; i = i + 1) sum = sum + i * i; printf ("The sum from 0 .. 100 is %d\n", sum); } FIGURE A.1.5 The routine written in the C programming language. FIGURE A.1.6 Assembly language either is written by a programmer or is the output of a compiler. Program Compiler Assembler Linker Computer High-level language program Assembly language program
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有