Page 125 - A Practical Guide from Design Planning to Manufacturing
P. 125

98   Chapter Four

        Instructions

        Today almost all software is written in “high-level” programming lan-
        guages. Computer languages such as C, Perl, and HTML were specifi-
        cally created to make software more readable and to make it independent
        of a particular computer architecture. High-level languages allow the
        program to concisely specify relatively complicated operations. A typical
        instruction might look like:

                If (A + B = 5) then...  # Jump if sum of A and B is 5

          To perform the same operation in instructions specific to a particular
        processor might take several instructions.
           ADD AX, BX      # Add BX to AX and store in AX
            CMP AX, 5      # Compare value in AX to 5
               BRE 16      # Branch to instruction 16 bytes ahead if equal

          These are assembly language instructions, which are specific to a par-
        ticular computer architecture. Of course, even assembly language instruc-
        tions are just human readable mnemonics for the binary encoding of
        instructions actually understood by the processor. The encoded binary
        instructions are called machine language and are the only instructions
        a processor can execute. Before any program is run on a real processor,
        it must be translated into machine language. The programs that perform
        this translation for high-level languages are called compilers. Translation
        programs for assembly language are called assemblers. The only differ-
        ence is that most assembly language instructions will be converted to a
        single machine language instruction while most high-level instructions
        will require multiple machine language instructions.
          Software for the very first computers was written all in assembly and
        was unique to each computer architecture. Today almost all programming
        is done in high-level languages, but for the sake of performance small
        parts of some programs are still written in assembly. Ideally, any program
        written in a high-level language could be compiled to run on any proces-
        sor, but the use of even small bits of architecture specific code make con-
        version from one architecture to another a much more difficult task.
          Although architectures may define hundreds of different instructions,
        most processors spend the vast majority of their time executing only a
        handful of basic instructions. Table 4-2 shows the most common types of
        operations for the x86 architecture for the five SPECint92 benchmarks. 1



          1
          Hennessy and Patterson, Computer Architecture, 109.
   120   121   122   123   124   125   126   127   128   129   130