⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ds.doc

📁 一个C style Assembler的source code
💻 DOC
字号:
                      OBJECT FILE FORMAT, and                      OBJECT FILE DiSPLAY UTILITY(0) COMMAND LINE, INPUT FORMAT   This utility will display the contents of an object file created by theassembler.  The command line is typically of the form:                     ds file.o >file.xThe contents of an object file are as follows:   HEADER, IMAGE, FILES, SEGMENTS, GAPS, SYMBOLS, EXPRESSIONS, RELOCATIONS   (a) HEADER      Bytes   Item        2     55aa ... the MAGIC number        4     Location of first item past the end of the memory IMAGE.        4     Number of FILES listed.        4     Number of SEGMENTS listed.        4     Number of GAPS listed.        4     Number of SYMBOLS listed.        4     Number of unresolved EXPRESSIONS listed.        4     Number of RELOCATION items listed.        4     Check sum of the previous 7 items.   (b) IMAGE   This is a binary listing of each of the code segments contained inthis object file, all concatentated together.  This binary format is listedby the display program 16 bytes per line, each byte written in hexadecimalform.  It is also displayed in character form to the right-hand side, in orderto show off any embedded strings.   The size of the image is given in two ways: (a) it is the sum of the sizesof all the code segments listed minus all the sizes of all the gaps listed, and(b) it is the number of bytes contained between the end of the header and theend of the image (which is indicated in the header).   (c) FILES   Source and header file names are added to the object file as needed to helpthe linker determine where any errors may be originating from.  Each file islisted in the following form:                  Bytes          Item                    1            L = length of file name                    L            file name   (d) SEGMENTS   The segments 0 through 4 are only used internally by the assembler.  Theyhave the types respectively code, xdata, data, sfr, and bit.  Their sizes are0, bases are 0, and they are absolute.  These segments serve as defaultsegments for absolute addresses.   The remaining segments (if there are any) are listed in the followingformat:                ## Line File Rel Type Base Size  Locwhich indicate, respectively, the segment's number, the line and file where itis first defined, whether it is relative, the segment's type (0 = code,1 = xdata, 2 = data, 3 = sfr, and 4 = bit, 3 and 4 are never seen).  The Baseis 0 for relative segments, else it points to the actual starting address of thesegment.  The Size is the number of bytes in the segment, and (for codesegments) Loc is the place in the object file where its image is found.   Each segment is formatted in the object file as follows:                  Bytes          Item                    2            Line                    2            File                    2            Bits 0-7 = Type                                 Bit 8 = 1 for relative segments, 0 else.                    2            Size                    2            Base                    4            LocThe file number indicated indexes the appropriate entry in the file listpreviously described.   (d) GAPS   Gaps are subsets of segments that are reserved but that have nocorresponding memory image.  No memory output is generated for gaps.They are displayed in the following format:                        ##  Seg  Off Sizewhere Seg, and Off are the segment where the gap occurs and its offsetwithin the segment.  Size is the size of the gap.   Two constraints will apply for valid object files: (1) every gap willbe located entirely within its segment (Off + Size < segment's size), and(2) only code segments contain gaps.   Each gap is formatted in the object file as follows:                  Bytes          Item                    2            Segment index                    2            Offset                    2            Size   (e) SYMBOLS   Each symbol is displayed in the following format:             ##     Scope Var Type   Value  Namewhere ## is the symbol's index, Scope is defined in terms of the GLOBALand DEFINED attributes as follows:               Scope           GLOBAL    DEFINED               undefined               local                        x               external          x               global            x          xVar is marked if the symbol is a variable.  Variables and global/externalsare disjoint.  Its type and value will be displayed as one of the following:                      ADDR  Seg   Offset                      NUM   ValueThe first case indicates a symbol defined as an address.  Its segment indexand offset are then listed.  The second case indicates numeric value.  Theactual value is then listed.  Offset and Value are listed in hexadecimalformat.  Neither the Offset nor Value are applicable if the symvol is notdefined (external or undefined).  Seg is inapplicable if the symbol istotally undefined.   Following this is the symbol's name.   Each symbol is formatted in the object file as follows:                  Bytes          Item                    1            Bit 0: 1 if variable, 0 if constant                                 Bit 1: 1 if address, 0 if numeric                                 Bit 2: DEFINED                                 Bit 3: GLOBAL                    2            Segment index                    2            Offset/Value                    2            L = Length of symbol name                    L            Symbol name   (f) EXPRESSIONS   These items represent expressions that could not be evaluated from theinformation presented in the source files.  Expression evaluation is deferredto the linker if the expression contains relative addresses, or externallydefined symbols.   They are displayed as follows:                     ## Line File  Tag Args...where the first 3 items are respectively the epxressions's index, and the lineand file where it is defined.  Tag and args will take on one of the sets ofvalues:             Descriuption      Tag  Args             Number             0   Value             Address            1   Seg           Offset             Symbol             2   Symbol Name             Unary operation    3   Unary         A             Binary operation   4   Binary        A        B             Conditional        5   A             B        Cwhere A, B, and C are indexes of previously defined expression occurring earlierin the list, Symbol Name is the name of the symbol which the expression is setto, Seg and Offset are the segment and offset of an address expression, Valueis the numeric value of a numeric expression, and Binary and Unary aresymbolic number for operators defiend as follows:                            Unary Operators                           Operator   Value                              ~         27                              !         28                             high       29                             low        30                              +         31                              -         32                           Binary Operators                           Operator   Value                              +         31                              -         32                              *         33                              /         34                              %         35                              <         36                              <=        37                              >         38                              >=        39                              ==        40                              !=        41                              &&        42                              ||        43                              &         44                              ^         45                              |         46                              <<        47                              >>        48                              .         49                              by        50   The format of an expression in the object file is as follows:                  Bytes          Item                    2            Line                    2            File                    1            Tagwith the following cases:            (i) Numeric (Tag = 0)                     Number                  Bytes          Item                    2            Value            (i) Address (Tag = 1)                     Segment:Offset                  Bytes          Item                    2            Segment Index                    2            Offset            (i) Symbol (Tag = 2)                      Symbol                  Bytes          Item                    2            Symbol Index            (i) Unary operation (Tag = 3)             Op A                  Bytes          Item                    1            Operator                    2            Expression A's index.            (i) Binary operation (Tag = 4)            A Op B                  Bytes          Item                    1            Operator                    2            Expression A's index.                    2            Expression B's index.            (i) Conditional operation (Tag = 5)       A? B: C                  Bytes          Item                    2            Expression A's index.                    2            Expression B's index.                    2            Expression C's index.                      (g) RELOCATIONS   A relocation item indicates an unevaluated expression, some information aboutits addressing mode, and the segment and offset where it is to be patched.These are items that the assembler could not properly determine because externalreferences were used or relative addressing was used.  All relocations refer topositions within code segments, since only code segments have memory images.   A relocation item is displayed as follows:              Line File Tag  Exp  Seg: Offwhere Line and File determine the corresponding point in the source file, Segand Off refer to the location where the patch is to be applied, Exp is the itemto be patched, and Tag is the type of reliocation defined as follows:                      Tag       Description                       b        Byte-sized constant                       w        Word-sized constant                       B        Bit address                       D        Direct register address                                   Data address < 80h                                or SFR address >= 80h.                       R        Relative code address                       P, Q     Paged code address.                       L        Absolute (long) code address.   Relocation items are formatted in the object file as follows:                  Bytes          Item                    2            Line                    2            File                    1            Tag                    2            Expression index                    2            Segment index                    2            Offset

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -