Assemblers, linkers, and the spim simulator

Páginas: 65 (16032 palabras) Publicado: 19 de marzo de 2012
A
A P P E N D I X

Assemblers, Linkers, and the SPIM Simulator
James R. Larus Microsoft Research Microsoft

Fear of serious injury cannot alone justify suppression of free speech and assembly.
Louis Brandeis Whitney v. California, 1927

A.1 A.2 A.3 A.4 A.5 A.6 A.7 A.8 A.9 A.10 A.11 A.12

Introduction A-3 Assemblers A-10 Linkers A-18 Loading A-19 Memory Usage A-20 Procedure CallConvention A-22 Exceptions and Interrupts A-33 Input and Output A-38 SPIM A-40 MIPS R2000 Assembly Language A-45 Concluding Remarks A-81 Exercises A-82

A.1

Introduction

A.1

Encoding instructions as binary numbers is natural and efficient for computers. Humans, however, have a great deal of difficulty understanding and manipulating these numbers. People read and write symbols (words) muchbetter than long sequences of digits. Chapter 2 showed that we need not choose between numbers and words because computer instructions can be represented in many ways. Humans can write and read symbols, and computers can execute the equivalent binary numbers. This appendix describes the process by which a human-readable program is translated into a form that a computer can execute, provides a few hintsabout writing assembly programs, and explains how to run these programs on SPIM, a simulator that executes MIPS programs. UNIX, Windows, and Mac OS X versions of the SPIM simulator are available on the CD. Assembly language is the symbolic representation of a computer’s binary encoding—machine language. Assembly language is more readable than machine language because it uses symbols instead ofbits. The symbols in assembly language name commonly occurring bit patterns, such as opcodes and register specifiers, so people can read and remember them. In addition, assembly language

machine language Binary representation used for communication within a computer system.

A-4

Appendix A

Assemblers, Linkers, and the SPIM Simulator

Source file

Assembler

Object file

Sourcefile

Assembler

Object file

Linker

Executable file

Source file

Assembler

Object file

Program library

FIGURE A.1.1 The process that produces an executable file. An assembler translates a file of assembly language into an object file, which is linked with other files and libraries into an executable file.

assembler A program that
translates a symbolic version of an instructioninto the binary version.

macro A pattern-matching and
replacement facility that provides a simple mechanism to name a frequently used sequence of instructions.

unresolved reference A reference that requires more information from an outside source in order to be complete. linker Also called link editor. A
systems program that combines independently assembled machine language programs andresolves all undefined labels into an executable file.

permits programmers to use labels to identify and name particular memory words that hold instructions or data. A tool called an assembler translates assembly language into binary instructions. Assemblers provide a friendlier representation than a computer’s 0s and 1s that simplifies writing and reading programs. Symbolic names for operationsand locations are one facet of this representation. Another facet is programming facilities that increase a program’s clarity. For example, macros, discussed in Section A.2, enable a programmer to extend the assembly language by defining new operations. An assembler reads a single assembly language source file and produces an object file containing machine instructions and bookkeeping information thathelps combine several object files into a program. Figure A.1.1 illustrates how a program is built. Most programs consist of several files—also called modules— that are written, compiled, and assembled independently. A program may also use prewritten routines supplied in a program library. A module typically contains references to subroutines and data defined in other modules and in libraries. The...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Linkers And Connectors
  • The Beauty And The Beast
  • The west and the rest
  • The old man and the sea
  • The ant and the grasshopper
  • The Drugs And Their Consequences
  • The Old Man And The Sea
  • The Lamb And The Tiger

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS