8086/186 Assembler, Linker, Librarian Notice
Total Page:16
File Type:pdf, Size:1020Kb
User’s Guide HP B1449 8086/186 Assembler, Linker, Librarian Notice Hewlett-Packard 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. Hewlett-Packard shall not be liable for errors contained herein or for incidental or consequential damages in connection with the furnishing, performance, or use of this material. Hewlett-Packard assumes no responsibility for the use or reliability of its software on equipment that is not furnished by Hewlett-Packard. © Copyright 1988, 1990, 1991, 1993, Hewlett-Packard Company. This document contains proprietary information, which is protected by copyright. All rights are reserved. No part of this document may be photocopied, reproduced or translated to another language without the prior written consent of Hewlett-Packard Company. The information contained in this document is subject to change without notice. Microtec is a registered trademark of Microtec Research Inc. SunOS, SPARCsystem, OpenWindows, and SunView are trademarks of Sun Microsystems, Inc. UNIX is a registered trademark of UNIX System Laboratories Inc. in the U.S.A. and other countries. Hewlett-Packard Company P.O . Box 2197 1900 Garden of the Gods Road Colorado Springs, CO 80901-2197, U.S.A. RESTRICTED RIGHTS LEGEND Use, duplication, or disclosure by the U.S. Government is subject to restrictions set forth in subparagraph (C) (1) (ii) of the Rights in Technical Data and Computer Software Clause in DFARS 252.227-7013. Hewlett-Packard Company, 3000 Hanover Street, Palo Alto, CA 94304 U.S.A. Rights for non-DOD U.S. Government Departments and Agencies are set forth in FAR 52.227-19(c)(1,2). ii About this edition Many product updates and fixes do not require manual changes, and manual corrections may be done without accompanying product changes. Therefore, do not expect a one-to-one correspondence between product updates and manual revisions. Edition dates and the corresponding HP manual part numbers are as follows: Edition 1 64871-90901, October 1988 E1088 Edition 2 64871-97004, July 1991 Edition 3 B1449-97000, April 1993 B1449-97000 incorporates information which previously appeared in 64871-97004, 64871-97005, 64871-97006, and 64871-92003. Certification and Warranty Certification and warranty information can be found at the end of this manual on the pages before the back cover. iii Features The as86 assembler: • generates code for the complete Intel 8086/8088 and 80186/188 instruction set • generates code for NEC V20/V30 extensions to 8086/186 instruction set • supports Intel 8087 floating-point coprocessor instructions • permits repeated definition of the same or of different code, data, and constants segments within a single source file • has high-level data structures for structured data types, bit fields, and symbolic memory references • allows control of the assembly process (conditional assembly, structured control, listing and output control) through a flexible set of assembly control statements • produces extensive program listings that can include symbol table/cross reference information • as part of the HP B1449 8086/186 Advanced Cross Assembler/Linker package, is well-integrated with the HP B1493 8086/186 C Advanced Cross Compiler • comes with a powerful, string-oriented macro preprocessor. The macro preprocessor adds even more flexibility to the assembler with its features (including support for recursive macros). The ld86 linking loader: • produces relocatable object modules for later re-linking (incremental linking) • produces absolute object modules in HP-OMF 86 format absolute, Intel Hexadecimal Object file format absolute, or HP 64000 format absolute • can include symbols in the absolute object module for symbolic debugging • allows independent specification of all relocatable segment load addresses • allows specification of relocatable segment loading order • supports segment groupings into either GROUP or CLASS • allows definition of public symbols, or changes to the memory locations of previously-defined public, at load-time (except for incremental links) • can generate a cross reference table of public symbols and the modules in which they are referenced, and also a memory map iv • can load object modules from a user library created by the ar86 librarian • can make a copy of initialized data values that can be placed in ROM • gives detailed, well-documented error messages The ar86 librarian: • produces libraries that can be loaded by the linking loader • can add, delete or replace individual modules in a library • can display library directories • supports batch command line input and return codes for make-type procedures • has an optimized structure for fast access during load-time • can be run in interactive mode as well as batch mode • can accept Intel library files as input v In This Book This book is organized into three parts: Part 1. Quick Start Guide A short lesson to get you started and summaries of command syntax. Part 2. Assembler/Macro Preprocessor Reference Detailed information about the assembler and macro preprocessor. Part 3. Linker/Librarian Reference Detailed information about the linker and librarian. Part 4. Error Messages Reference Lists of the error messages you might see during the assembly/linking process, and what to do about them. vi Contents Part 1 Quick Start Guide 1 Getting Started Objectives of the Example Program 2 Description of the Example Program 3 The "mov_mesg.s" Program Module 3 The "transfer.s" Program Module 7 The "delay.s" Program Module 8 Assembling the Program Module Source Files 9 Starting the Macro Preprocessor 9 Starting the Assembler 9 Viewing the Assembler Listing Files 9 Creating an Example Library File 15 Linking the Program Module Relocatable Object Files 17 Linking the Object Modules 18 vii Contents 2 Command Syntax as86(1) 23 ap86(1) 30 ld86(1) 32 ar86(1) 45 Part 2 Assembler/Macro Preprocessor Reference 3 Assembler Introduction Instruction Set 52 Target Microprocessors 52 Assembler Operation 52 File Formats 53 Input File Characteristics 53 Output File Characteristics 53 4 Assembler Syntax Assembler Character Set 56 ASCII Codes 58 Symbols 59 Symbol Formation 59 Keywords 60 Instruction Mnemonics 62 Codemacro 62 Label 62 viii Contents Variable 62 Structure Name 63 Structure Field Name 63 Record Name 63 Record Field Name 63 Segment Name 64 Group Name 64 EQU Symbols 64 Constants 64 Integer Constant 65 Real Constant 66 Character Constant 67 Delimiters 68 Assembler Statements 68 General Syntax 68 Comment 69 Continuation Lines 70 5 Symbol and Expression Attributes TYPE 73 OFFSET 73 BASE 74 INDEX 74 SEGMENT 75 SEGMENT RELOCATION 75 RELOCATION TYPE 75 SEGMENT ADDRESSABILITY 76 CS ADDRESSABILITY 77 6 Assembler Directives Segmentation Directives 81 Program Segmentation 81 Default Segment - ??SEG 82 ix Contents Data Definition Directives 83 Data Objects 83 Linkage Directives 84 Program Linkage 84 ASSUME 86 DB, DW, DD, DQ, DT 88 END 94 EQU 96 EVEN 99 EXTRN 100 GROUP 103 LABEL 105 NAME 107 ORG 108 PROC/ENDP 109 PUBLIC 111 PURGE 112 RECORD 114 SEGMENT/ENDS 118 STRUC/ENDS 123 7Expressions Reference Syntax Conventions 128 Expression Overview 128 Absolute Expression 129 Relocatable Expression 130 External Expression 130 Expression Operands 131 Numeric Values 131 Memory and Register Expressions 133 EQU 136 Expression Operators Introduction 137 Arithmetic Operators 137 Unary Plus, Unary Minus 137 x Contents Binary Addition, Subtraction 138 [ ] Square Brackets 139 . (Dot operator) 140 Multiplication, Division, Modulo 141 SHL, SHR 142 HIGH, LOW 143 Logical Operators 144 AND, OR, XOR 144 NOT 145 EQ, NE, LT, LE, GT, GE 145 Memory Operators 146 SHORT 146 THIS 146 PTR 147 Segment or Group Override 148 OFFSET 149 SEG 149 TYPE 150 LENGTH 151 SIZE 152 Record Operators 154 MASK 154 WIDTH 154 Segment and Group Operators 156 SEGOFFSET 156 GRPOFFSET 156 SEGSIZE 157 GRPSIZE 158 Operator Precedence 159 8 Instructions and Operands Operands 162 Accepted Operands 162 xi Contents Operand Positioning 164 Immediate Values 164 Registers 165 Memory Expressions and the MODRM Byte 169 Segment Addressability and Overrides 170 Addressability Checking 171 Default Segments 171 Segment Overrides 172 Improper Uses of Segment Overrides 172 Segment Override Byte 172 Overrides and Checking Against ASSUME 173 Segment Override Byte Generation 173 The Instruction Set 174 as86 Assembler Instruction Set 176 9 Assembler Controls General Syntax for Assembler Controls 195 Primary and General Controls 195 Controls on the Command Line 195 Control Conflicts 196 Controls and File Names 196 Control Abbreviations 196 Controls and the Macro Preprocessor (ap86) 196 Primary Controls 197 [NO]CASE 197 DATE(string) 197 [NO]DEBUG 198 [NO]ERRORPRINT (filename) 198 [NO]EXTERN_CHECK 198 GEN 199 GENONLY 199 [NO]GROUP_INFO 199 [NO]HLASSYM 200 [NO]MACRO(string) 200 MOD086 200 xii Contents MOD186 201 MODV20 201 [NO]OBJECT (filename) 201 [NO]OPTIMIZE 202 PAGELENGTH(n) 202 PAGEWIDTH(n) 202 [NO]PAGING 203 [NO]PRINT(filename) 203 [NO]SYMBOLS 204 [NO]TYPE 204 [NO]UNREFERENCED_EXTERNALS 204 [NO]WARNING 205 WORKFILES( ... ) 205 [NO]XREF 205 General Controls 206 EJECT 206 [NO]GEN 206 GENONLY 206 INCLUDE(filename) 207 [NO]LIST 207 RESTORE 207 SAVE 208 TITLE(string) 208 Operational Differences in the Different Modes 209 8086 Mode 209 80186 Mode 209 V20 Mode 209 xiii Contents 10 Assembler Listing Description Assembly Listing 212 Cross Reference and Symbol Table Format Description 213 11 Codemacros Referencing Codemacros 218 Codemacro