Xenix* 286 Programmer's Guide
Total Page:16
File Type:pdf, Size:1020Kb
inter XENIX* 286 PROGRAMMER'S GUIDE *XENIX is a trademark of Microsoft Corporation. Copyright @ 1984, Intel Corporation Order Number: 174391-001 Intel Corporation, 3065 Bowers Avenue, Santa Clara. Callfornld 95051 XENIX* 286 PROGRAMMER'S GUIDE Order Number: 174391-001 *XENIX is a trademark of Microsoft Corporation COPYright © 1984 Intel Corporation I Intel Corporation, 3065 Bowers Avenue, Santa Clara, California 95051 I The information in this document is subject to change without notice. Intel Corporation makes no warranty of any kind with regard to this material, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. Intel Corporation assumes no responsibility for any errors that may appear in this document. Intel Corporation makes no commitment to update or to keep current the information contained in this document. Intel Corporation assumes no responsibility for the use of any circuitry other than circuitry embodied in an Intel product. No other circuit patent licenses are implied. Intel software products are copYrighted by and shall remam the property ofIntel Corporation. Use, duplication or disclosure is subject to restrictions stated in Intel's software license, or as defined in ASPR 7-104.9 (a) (9). No part of this document may be copIed or reproduced in any form or by any means without prior written consent of Intel Corporation. The following are trademarks ofIntel Corporation and its affiliates and may be used only to identify Intel products: BITBUS im iRMX Open NET COMMputer iMDDX iSBC Plug-A-Bubble CREDIT iMMX iSBX PROMPT Data Pipeline Insite iSDM Promware Genius intel iSXM QUEST A 1 intelBOS KEPROM QueX i Intelevision Library Manager Ripplemode I2ICE inteligent Identifier MCS RMXJ80 ICE inteligent Programming Megachassis RUPI iCS Intellec MICROMAINFRAME Seamless iDBP Intellink MULTIBUS SLD iDIS iOSP MULTICHANNEL SYSTEM 2000 iLBX iPDS MUL TIMODULE UPI XENIX is a trademark of Microsoft Corporation. Microsoft is a trademark of Microsoft Corporation. UNIX is a trademark of Bell Laboratories. REV. REVISION HISTORY DATE -001 Original issue 11/84 ii 10/84 TABLE OF CONTENTS CONTENTS CHAPTER 1 PAGE INTRODUCTION Prerequisites 1-1 Manual Organization 1-1 Notation 1-2 CHAPTER 2 cc: C COMPILER Invoking the C Compiler 2-1 Creating Programs from C Source Files 2-2 Compiling a C Source File 3-2 Compiling Several Source Files 2-3 Naming the Output File 2-4 Creating Small, Middle, and Large Programs 2-4 Creating Small Model Programs 2-5 Creating Pure-Text Small Model Programs 2-6 Creating Middle Model Programs 2-6 Creating Large Model Programs 2-6 Using Object Files and Libraries 2-7 Creating Object Files 2-7 Creating Programs from Object Files 2-8 Linking a Program to Functions in Libraries 2-8 Creating Smaller and Faster Programs 2-9 Creating Optimized Object Files 2-9 Stripping the Symbol Table 2-9 Removing Stack Probes from a Program 2-10 Preparing Programs for Debugging 2-10 Producing an Assembly Language Listing 2-11 Profiling a Program 2-11 Controlling the C Preprocessor 2-12 Defining a Macro 2-12 Defining Include Directories 2-13 Ignoring the Default Include Directories 2-14 Saving a Preprocessed Source File 2-14 Error Messages 2-14 C Compiler Messages 2-15 Setting the Level of Warnings 2-15 Using Advanced Options 2-16 Creating Programs from Assembly Language Source Files 2-16 Using the near and far Keywords 2-17 Changing Word Order in Programs 2-18 Setting the Stack Size 2-18 Using Modules, Segments, and Groups 2-18 iii Table of Contents XENIX Program ming CONTENTS PAGE Compiler Summary 2-20 cc Options 2-20 Memory Models 2-22 Pointer and Integer Sizes 2-22 Segment and Module Names 2-22 CHAPTER 3 lint: C PROGRAM CHECKER Invoking lint 3-1 Checking for Unused Variables and Functions 3-2 Checking Local Variables 3-3 Checking for Unreachable Statements 3-4 Checking for Infinite Loops 3-5 Checking Function Return Values 3-5 Checking for Unused Return Values 3-6 Checking Types 3-6 Checking Type Casts 3-7 Checking for Nonportable Character Use 3-7 Checking for Assignment of longs to ints 3-8 Checking for Strange Constructions 3-8 Checking for Use of Older C Syntax 3-9 Checking Pointer Alignment 3-10 Checking Expression Evaluation Order 3-11 Embedding Directives 3-11 Checking for Library Compatibility 3-12 CHAPTER 4 make: PROGRAM MAINTAINER Creating a Makefile 4-1 Invoking make 4-3 Using Pseudo-Target Names 4-4 Using Macros 4-5 Using Shell Environment Variables 4-7 Using the Built-In Rules 4-8 Changing the Built-In Rules 4-9 Using Libraries 4-11 Troubleshooting 4-12 Using make: An Example 4-13 CHAPTER 5 SCCS: SOURCE CODE CONTROL SYSTEM Basic Information 5-1 Files and Directories 5-1 Deltas and SIDs 5-2 SCCS Working Files 5-3 SCCS Command Arguments 5-4 File Administrator 5-4 Creating and Using s-files 5-4 Creating an s-file 5-5 Retrieving a File for Reading 5-5 Retrieving a File for Editing 5-6 iv XENIX Programming Table of Contents CONTENTS PAGE Saving aNew Version of a File 5-7 Retrieving a Specific Version 5-8 Changing the Release Number of a File 5-9 Creating a Branch Version 5-10 Retrieving a Branch Version 5-10 Retrieving the Most Recent Version 5-11 Displaying a Version 5-11 Saving a Copy of a New Version 5-12 Displaying Helpful Information 5-12 Using Identification Keywords 5-13 Inserting a Keyword into a File 5-13 Assigning Values to Keywords 5-14 Forcing Keywords 5-14 Using s-file Flags 5-14 Setting s-file Flags 5-15 Using the i Flag 5-15 Using the d Flag 5-15 Using the v Flag 5-16 Removing an s-file Flag 5-16 Modifying s-file Information 5-16 Adding Comments 5-17 Changing Comments 5-17 Adding Modification Requests 5-18 Changing Modification Requests 5-18 Adding Descriptive Text 5-19 Printing from an s-file 5-19 Using a Data Specification 5-19 Printing a Specific Version 5-20 Printing Later and Earlier Versions 5-20 Editing by Several Users 5-21 Editing Different Versions 5-21 Editing a Single Version 5-21 Saving a Specific Version 5-22 Protecting s-files 5-22 Adding a User to the User List 5-22 Removing a User from a User List 5-23 Setting the Floor Flag 5-23 Setting the Ceiling Flag 5-23 Locking a Version 5-24 Repairing SCCS Files 5-24 Checking an s-file 5-24 Editing an s-file 5-25 Changing an s-file's Checksum 5-25 Regenerating a g-file for Editing 5-25 Restoring a Damaged p-file 5-25 Using Other Command Options 5-26 Getting Help with SCCS Commands 5-26 Creating a File with the Standard Input 5-26 Starting at a Specific Release 5-26 Adding a Com ment to the First Version 5-27 Suppressing Normal Output 5-27 Including and Excluding Deltas 5-28 v Table of Contents XENIX Programming CONTENTS PAGE Listing the Deltas of a Version 5-29 Mapping Lines to Deltas 5-29 Naming Lines 5-29 Displaying a List of Differences 5-30 Displaying File Information 5-30 Removing a Delta 5-30 Searching for Strings 5-31 Comparing SCCS Files 5-31 CHAPTER 6 adb: PROGRAM DEBUGGER Starting and Stopping adb 6-1 Starting with a Program File 6-1 Starting with a Core Image File 6-2 Starting adb with Data Files 6-3 Starting with the Write Option 6-3 Starting with the Prompt Option 6-3 Leaving adb 6-4 Displaying Instructions and Data 6-4 Forming Addresses 6-4 Forming Expressions 6-4 Decimal, Octal, and Hexadecimal Integers 6-5 Symbols 6-5 adb Variables 6-6 Current Address 6-7 Register Names 6-7 Operators 6-8 Choosing Data Formats 6-9 Using the = Command 6-10 Using the? and / Commands 6-11 An Example: Simple Formatting 6-12 Debugging Program Execution 6-13 Executing a Program 6-13 Setting Breakpoints 6-14 Displaying Breakpoints 6-15 Continuing Execution 6-15 Stopping a Program with Interrupt and Quit 6-16 Single-Stepping a Program 6-16 Killing a Program 6-16 Deleting Breakpoints 6-17 Displaying the C Stack Backtrace 6-17 Displaying CPU Registers 6-18 Displaying External Variables 6-18 An Example: Tracing Multiple Functions 6-18 Using the adb Memory Maps 6-22 Displaying the Memory Maps 6-22 Changing the Memory Map 6-24 Creating New Map Entries 6-24 Validating Addresses 6-25 Miscellaneous Features 6-25 Combining Commands on a Single Line 6-25 Creating adb Scripts 6-26 vi XENIX Programming Table of Contents CONTENTS PAGE Setting Output Width 6-26 Setting the Maximum Offset 6-27 Setting Default Input Format 6-27 Using XENIX Commands 6-28 Computing Numbers and Displaying Text 6-28 An Example: Directory and Inode Dumps 6-29 Patching Binary Files 6-30 Locating Values in a File 6-30 Writing to a File 6-31 Making Changes to Memory 6-31 CHAPTER 7 as: ASSEMBLER Command Usage 7-1 Lexical Conventions 7-2 Identifiers 7-2 Constants 7-2 White Space 7-2 Comments 7-2 Assembly Segments 7-3 Text, Data, and Bss Segments 7-3 The Location Counter 7-4 Statements 7-4 Labels 7-4 Null Statements 7-5 Expression Statements 7-5 Assignment Statements 7-5 Keyword Statements 7-6 Expressions 7-6 Expression Operators 7-6 Types 7-6 Type Propagation in Expressions 7-7 Assembler Directives 7-8 Even Directive 7-8 Floating-Point Directives 7-9 Global Directive 7-9 Segment Directives 7-9 Common Directive 7-10 Insert Directive 7-10 ASCII Directives 7-10 Listing Directives 7-11 Block Directives 7-11 Initial Value Directives 7-12 End Directive 7-12 Machine Instructions 7-12 Mnemonic List 7-12 Byte Instructions 7-16 Branch Instructions 7-17 String Instructions 7-17 Intersegment Instructions 7-18 Input/Output Instructions 7-18 80286 Instructions 7-18 vii Table of Contents XENIX Programming CONTENTS PAGE Addressing Modes 7-19 Register Operands 7-19 Immediate Operands 7-20 Direct Address Operands 7-20 Based Operands 7-21 Indexed Operands 7-21