The assembler converts assembly language statements into machine code. In instruction; however, some assembly language instructions can generate.
18 KB – 244 Pages
PAGE – 2 ============
Copyright Ó 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
PAGE – 3 ============
Assembly Language Programmer™s Guideiii Preface: About This BookThis 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™s 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. AudienceThis 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: Ł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. ŁAccess machine functions unavailable in high-level languages or satisfy special constraints such as restricted register usage. ŁChange the operating system. ŁChange the compiler system. Further system information can be obtained from the manuals listed at the end of this section.
PAGE – 4 ============
About This Book ivAssembly Language Programmer™s Guide Topics CoveredThis book has these chapters: ŁChapter 1: Registers describes the format for the general registers, the special registers, and the floating point registers. ŁChapter 2: Addressing describes how addressing works. ŁChapter 3: Exceptions describes exceptions you might encounter with assembly programs. ŁChapter 4: Lexical Conventions describes the lexical conventions that the assembler follows. ŁChapter 5: Instruction Set describes the main processor™s instruction set, including notation, load and store instructions, computational instructions, and jump and branch instructions. ŁChapter 6: Coprocessor Instruction Set describes the coprocessor instruction sets. ŁChapter 7: Linkage Conventions describes linkage conventions for all supported high-level languages. It also discusses memory allocation and register use. ŁChapter 8: Pseudo-Op-Codes describes the assembler™s pseudo- operations (directives). Ł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. Ł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. Ł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. Ł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. ŁAppendix A: Instruction Summary summarizes all assembler instructions. ŁAppendix B: Basic Machine Definition describes instructions that generate more than one machine instruction. ŁIndex. Contains index entries for this publication.
PAGE – 5 ============
About This Book Assembly Language Programmer™s Guidev Special Text Notations Several special notations are used throughout this manual to differentiate among the following types of information: Note kA 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): ŁRISCompiler and C Programmer™s Guide (Order number CMP-01-DOC) ŁMIPS RISC Architecture (Order number SYS-02-DOC) ŁMIPS RISC/os Programmer™s Reference Manual (ROS-01-DOC) ŁMIPS RISC/os User™s Reference Manual (ROS-02-DOC)
PAGE – 8 ============
viiiAssembly Language Programmer™s Guide Multiple Lines Per Physical Line..4-5 Statements..4-6 Label Definitions..4-6 Null Statements..4-7 Keyword Statements4-7 Expressions4-7 Precedence4-7 Expression Operators..4-8 Data Types4-8 Type Propagation in Expressions4-10 5Instruction Set Instruction Classes.5-1 Reorganization Constraints and Rules.5-2 Instruction Notation .5-2 Load and Store Instructions .5-3 Load and Store Formats.5-3 Load Instruction Descriptions.5-4 Store Instruction Descriptions.5-7 Computational Instructions5-10 Computational Formats5-10 Computational Instruction Descriptions.5-13 Jump and Branch Instructions..5-21 Jump and Branch Formats.5-21 Jump and Branch Instruction Descriptions5-23 Special Instructions ..5-25 Special Formats5-25 Special Instruction Descriptions.5-26 Coprocessor Interface Instructions.5-27 Coprocessor Interface Formats5-27 Coprocessor Interface Instruction Descriptions .5-28 6Coprocessor Instruction Set Instruction Notation..6-1 Floating-Point Instructions6-2 Floating-Point Formats..6-3 Floating-Point Load and Store Formats.6-3
PAGE – 9 ============
Assembly Language Programmer™s Guide ixFloating-Point Load and Store Descriptions6-4 Floating-Point Computational Formats..6-4 Floating-Point Computational Instruction Descriptions6-7 Floating-Point Relational Operations..6-8 Floating-Point Relational Instruction Formats.6-10 Floating-Point Relational Instruction Descriptions..6-11 Floating-Point Move Formats..6-13 Floating-Point Move Instruction Descriptions.6-13 System Control Coprocessor Instructions..6-13 System Control Coprocessor Instruction Formats.6-13 System Control Coprocessor Instruction Descriptions6-14 Control and Status Register .6-15 Floating-Point Rounding.6-20 7Linkage Conventions Introduction..7-1 Program Design..7-2 Register Use and Linkage.7-2 The Stack Frame7-3 The Shape of Data.7-7 Examples7-7 Learning by Doing..7-11 Calling a High-Level Language Routine7-11 Calling an Assembly Language Routine.7-13 Memory Allocation7-15 8Pseudo Op-Codes 9MIPS Object File Format Overview9-2 The File Header..9-4 File Header Magic Field (f_magic)..9-5 Flags (f_flags).9-5 Optional Header..9-7 Optional Header Magic Field (magic)9-8 Section Headers..9-8
PAGE – 10 ============
xAssembly Language Programmer™s Guide Section Name (s_name).9-9 Flags (s_flags)..9-10 Global Pointer Tables..9-11 Shared Library Information..9-12 Section Data9-12 Section Relocation Information9-15 Relocation Table Entry9-15 Assembler and Link Editor Processing ..9-16 Object Files.9-22 Impure Format (OMAGIC) Files9-23 Shared Text (NMAGIC) Files.9-24 Demand Paged (ZMAGIC) Files9-25 Target Shared Library (LIBMAGIC) Files9-28 Objects Using Shared Libraries..9-28 Ucode objects9-29 Loading Object Files.9-29 Archive files..9-30 Link Editor Defined Symbols9-31 Runtime Procedure Table Symbols..9-32 10Symbol Table Overview.10-2 Format of Symbol Table Entries.10-8 Symbolic Header.10-8 Line Numbers10-9 Procedure Descriptor Table10-13 Local Symbols..10-13 Optimization Symbols..10-17 Auxiliary Symbols..10-17 File Descriptor Table.10-20 External Symbols.10-21 11Execution and Linking Format Object File Format..11-2 ELF Header11-3 Sections.11-7 Section Header Table11-7
PAGE – 11 ============
Assembly Language Programmer™s Guide xiSection Header.11-8 Special Sections11-14 String Tables..11-18 ELF Symbol Table..11-18 Symbol Type..11-21 Symbol Values..11-22 Global Data Area..11-23 Register Information11-25 Relocation.11-26 12Program Loading and Dynamic Linking Program Header12-2 Base Address.12-4 Segment Permissions12-4 Segment Contents..12-5 Program Loading.12-6 Dynamic Linking.12-9 Program Interpreter12-9 Dynamic Linker..12-9 Dynamic Section..12-11 Shared Object Dependencies..12-18 Global Offset Table (GOT).12-19 Calling Position Independent Functions..12-20 Symbols.12-22 Relocations..12-22 Hash table.12-23 Initialization and Termination Functions.12-23 Quickstart.12-24 Shared Object List12-24 Conflict Section12-26 Ordering12-26 AInstruction Summary
18 KB – 244 Pages