Assembly Language Programmer's
244 pág.

Assembly Language Programmer's


DisciplinaProgramação Assembly24 materiais242 seguidores
Pré-visualização49 páginas
Part Number 02-00036-005
October 1992
Your comments on our products and publications 
are welcome. A postage-paid form is provided for 
this purpose on the last page of this manual.
MIPS
Assembly Language
Programmer\u2019s Guide
ASM-01-DOC
Copyright \uf6d9 1989-1992 Silicon Graphics, Inc. All Rights Reserved.
This manual documents MIPS Pascal version 3.10.
RISComputer, RISCwindows, and RISC/os are trademarks of Silicon Graphics,, Inc.
UNIX is a Trademark of UNIX System Laboratories, Inc.
Silicon Graphics, Inc.
2011 North Shoreline Blvd.
Mountain View, CA 94039-7311
Customer Service
U.S. and Canada: 1 (800) 800-4SGI
International: Contact your local sales representative
Assembly Language Programmer\u2019s Guide iii
Preface: About This Book
This book describes the assembly language supported by the RISCompiler 
system, its syntax rules, and how to write assembly programs. For 
information on assembling and linking an assembly language program, see 
the MIPS RISCompiler and C Programmer\u2019s Guide.
The assembler converts assembly language statements into machine code. In 
most assembly languages, each instruction corresponds to a single machine 
instruction; however, some assembly language instructions can generate 
several machine instructions. This feature results in assembly programs that 
can run without modification on future machines, which might have different 
machine instructions.
See Appendix B for more information about assembler instructions that 
generate multiple machine instructions.
Audience
This book assumes that you are an experienced assembly language 
programmer. The assembler produces object modules from the assembly 
instructions that the C, Fortran 77, and Pascal compilers generate. It therefore 
lacks many functions normally present in assemblers. You should use the 
assembler only when you need to:
\u2022 Maximize the efficiency of a routine, which might not be possible in 
C, Fortran 77, Pascal, or another high-level language; for example, to 
write low-level I/O drivers.
\u2022 Access machine functions unavailable in high-level languages or 
satisfy special constraints such as restricted register usage.
\u2022 Change the operating system.
\u2022 Change the compiler system.
Further system information can be obtained from the manuals listed at the end 
of this section.
About This Book
iv Assembly Language Programmer\u2019s Guide
Topics Covered
This book has these chapters: 
\u2022 Chapter 1: Registers describes the format for the general registers, 
the special registers, and the floating point registers.
\u2022 Chapter 2: Addressing describes how addressing works.
\u2022 Chapter 3: Exceptions describes exceptions you might encounter 
with assembly programs.
\u2022 Chapter 4: Lexical Conventions describes the lexical conventions 
that the assembler follows.
\u2022 Chapter 5: Instruction Set describes the main processor\u2019s 
instruction set, including notation, load and store instructions, 
computational instructions, and jump and branch instructions.
\u2022 Chapter 6: Coprocessor Instruction Set describes the coprocessor 
instruction sets.
\u2022 Chapter 7: Linkage Conventions describes linkage conventions for 
all supported high-level languages. It also discusses memory 
allocation and register use.
\u2022 Chapter 8: Pseudo-Op-Codes describes the assembler\u2019s pseudo-
operations (directives).
\u2022 Chapter 9: MIPSObject File Format provides an overview of the 
components comprising the object file and describes the headers and 
sections of the object file.
\u2022 Chapter 10: Symbol Table describes the purpose of the Symbol 
Table and the format of entries in the table. This chapter also lists the 
symbol table routines that are supplied.
\u2022 Chapter 11: Execution and Linking Format describes Execution 
and Linking Format (ELF) for object files. This chapter also 
describes the components of an elf object file, symbol table format, 
global data area, register information, and relocation.
\u2022 Chapter 12: Program Loading and Dynamic Linking describes the 
object file structures that relate to program execution. This chapter 
also describes how the process image is created from executable files 
and object files.
\u2022 Appendix A: Instruction Summary summarizes all assembler 
instructions.
\u2022 Appendix B: Basic Machine Definition describes instructions that 
generate more than one machine instruction.
\u2022 Index. Contains index entries for this publication.
About This Book
Assembly Language Programmer\u2019s Guide v
Special Text Notations
Several special notations are used throughout this manual to differentiate 
among the following types of information:
Note k
A note presents information of greater-than-normal importance.
Detail +
Printed in a sans serif font, a detail presents additional information 
that is of ancillary importance.
For More Information
 As you use this manual, consult the following book(s):
\u2022 RISCompiler and C Programmer\u2019s Guide
 (Order number CMP-01-DOC)
\u2022 MIPS RISC Architecture 
(Order number SYS-02-DOC)
\u2022 MIPS RISC/os Programmer\u2019s Reference Manual 
(ROS-01-DOC)
\u2022 MIPS RISC/os User\u2019s Reference Manual 
(ROS-02-DOC)
About This Book
vi Assembly Language Programmer\u2019s Guide
Assembly Language Programmer\u2019s Guide vii
Contents
Preface: About This Book
Audience...................................................................................................iii
Topics Covered.........................................................................................iv
Special Text Notations ..............................................................................v
For More Information................................................................................v
1
Registers
 Register Format .................................................................................1-1
Special Registers ...................................................................................1-5
2
Addressing 
Address Formats.....................................................................................2-2
Address Descriptions..............................................................................2-3
3
Exceptions
Main Processor Exceptions ....................................................................3-1
Floating-Point Exceptions .....................................................................3-2
4
Lexical Conventions
Tokens ....................................................................................................4-1
Comments...............................................................................................4-2
Identifiers................................................................................................4-2
Constants ................................................................................................4-2
Scalar Constants...............................................................................4-3
Floating Point Constants ..................................................................4-3
String Constants ...............................................................................4-4
viii Assembly Language Programmer\u2019s Guide
Multiple Lines Per Physical Line ...........................................................4-5
Statements...............................................................................................4-6
Label Definitions .............................................................................4-6
Null Statements................................................................................4-7
Keyword Statements ........................................................................4-7
Expressions.............................................................................................4-7
Precedence .......................................................................................4-7
Expression