正在加载图片...
A.1 Introduction A-5 00100111101111011111111111100000 10101111101111110000000000010100 10101111101001000000000000100000 10101111101001010000000000100100 10101111101000000000000000011000 10101111101000000000000000011100 10001111101011100000000000011100 10001111101110000000000000011000 00000001110011100000000000011001 00100101110010000000000000000001 00101001000000010000000001100101 10101111101010000000000000011100 00000000000000000111100000010010 898986889889999899 10101111101110010000000000011000 00111100000001000001000000000000 10001111101001010000000000011000 00001100000100000000000011101100 00100100100001000000010000110000 10001111101111110000000000010100 00100111101111010000000000100000 00000011111000000000000000001000 00000000000000000001000000100001 FIGURE A.1.2 MIPS machine language code for a routine to compute and print the sum of the squares of integers between 0 and 100. routine is much easier to read because operations and operands are written with symbols,rather than with bit patterns.However,this assembly language is still difficult to follow because memory locations are named by their address,rather than by a symbolic label. Figure A.1.4 shows assembly language that labels memory addresses with mne- monic names.Most programmers prefer to read and write this form.Names that begin with a period,for example.data and globl,are assembler directives assembler directive An opera- that tell the assembler how to translate a program but do not produce machine tion that tells the assembler how instructions.Names followed by a colon,such as str or main,are labels that to translate a program but does name the next memory location.This program is as readable as most assembly not produce machine instruc- language programs(except for a glaring lack of comments),but it is still difficult tions;always begins with a period. to follow because many simple operations are required to accomplish simple tasks and because assembly language's lack of control flow constructs provides few hints about the program's operation. By contrast,the C routine in Figure A.1.5 is both shorter and clearer since vari- ables have mnemonic names and the loop is explicit rather than constructed with branches.In fact,the C routine is the only one that we wrote.The other forms of the program were produced by a C compiler and assembler. In general,assembly language plays two roles(see Figure A.1.6).The first role is the output language of compilers.A compiler translates a program written in aA.1 Introduction A-5 routine is much easier to read because operations and operands are written with symbols, rather than with bit patterns. However, this assembly language is still difficult to follow because memory locations are named by their address, rather than by a symbolic label. Figure A.1.4 shows assembly language that labels memory addresses with mne￾monic names. Most programmers prefer to read and write this form. Names that begin with a period, for example .data and .globl, are assembler directives that tell the assembler how to translate a program but do not produce machine instructions. Names followed by a colon, such as str or main, are labels that name the next memory location. This program is as readable as most assembly language programs (except for a glaring lack of comments), but it is still difficult to follow because many simple operations are required to accomplish simple tasks and because assembly language’s lack of control flow constructs provides few hints about the program’s operation. By contrast, the C routine in Figure A.1.5 is both shorter and clearer since vari￾ables have mnemonic names and the loop is explicit rather than constructed with branches. In fact, the C routine is the only one that we wrote. The other forms of the program were produced by a C compiler and assembler. In general, assembly language plays two roles (see Figure A.1.6). The first role is the output language of compilers. A compiler translates a program written in a 00100111101111011111111111100000 10101111101111110000000000010100 10101111101001000000000000100000 10101111101001010000000000100100 10101111101000000000000000011000 10101111101000000000000000011100 10001111101011100000000000011100 10001111101110000000000000011000 00000001110011100000000000011001 00100101110010000000000000000001 00101001000000010000000001100101 10101111101010000000000000011100 00000000000000000111100000010010 00000011000011111100100000100001 00010100001000001111111111110111 10101111101110010000000000011000 00111100000001000001000000000000 10001111101001010000000000011000 00001100000100000000000011101100 00100100100001000000010000110000 10001111101111110000000000010100 00100111101111010000000000100000 00000011111000000000000000001000 00000000000000000001000000100001 FIGURE A.1.2 MIPS machine language code for a routine to compute and print the sum of the squares of integers between 0 and 100. assembler directive An opera￾tion that tells the assembler how to translate a program but does not produce machine instruc￾tions; always begins with a period
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有