Initial revision
[fw/sdcc] / as / doc / format.txt
1         2.5.1  Object Module Format 
2
3
4            The  first  line  of  an object module contains the [XDQ][HL]
5         format specifier (i.e.  XH indicates  a  hexidecimal  file  with
6         most significant byte first) for the following designators.  
7
8
9         2.5.2  Header Line 
10
11                 H aa areas gg global symbols 
12
13            The  header  line  specifies  the number of areas(aa) and the
14         number of global symbols(gg) defined or referenced in  this  ob-
15         ject module segment.  
16
17
18         2.5.3  Module Line 
19
20                 M name 
21
22            The  module  line  specifies  the module name from which this
23         header segment was assembled.  The module line will  not  appear
24         if the .module directive was not used in the source program.  
25
26
27         2.5.4  Symbol Line 
28
29                 S string Defnnnn 
30
31                         or 
32
33                 S string Refnnnn 
34
35            The  symbol line defines (Def) or references (Ref) the symbol
36         'string' with the value nnnn.  The defined value is relative  to
37         the  current  area  base  address.   References to constants and
38         external global symbols will always appear before the first area
39         definition.  References to external symbols will have a value of
40         zero.  
41
42
43         2.5.5  Area Line 
44
45                 A label size ss flags ff 
46
47            The  area  line  defines the area label, the size (ss) of the
48         area in bytes, and the area flags (ff).  The area flags  specify
49         the ABS, REL, CON, OVR, and PAG parameters:  
50
51                 OVR/CON  (0x04/0x00 i.e.  bit position 2) 
52
53                 ABS/REL  (0x08/0x00 i.e.  bit position 3) 
54
55                 PAG      (0x10 i.e.  bit position 4) 
56
57
58         2.5.6  T Line 
59
60                 T xx xx nn nn nn nn nn ...  
61
62            The  T  line contains the assembled code output by the assem-
63         bler with xx xx being the offset address from the  current  area
64         base address and nn being the assembled instructions and data in
65         byte format.  
66
67
68         2.5.7  R Line 
69
70                 R 0 0 nn nn n1 n2 xx xx ...  
71
72            The R line provides the relocation information to the linker.
73         The nn nn value is the current area index, i.e.  which area  the
74         current  values  were  assembled.  Relocation information is en-
75         coded in groups of 4 bytes:  
76
77              1.  n1 is the relocation mode and object format 
78                  1.  bit 0 word(0x00)/byte(0x01) 
79                  2.  bit 1 relocatable area(0x00)/symbol(0x02) 
80                  3.  bit 2 normal(0x00)/PC relative(0x04) relocation 
81                  4.  bit  3  1-byte(0x00)/2-byte(0x08) object format for
82                      byte data 
83                  5.  bit 4 signed(0x00)/unsigned(0x10) byte data 
84                  6.  bit 5 normal(0x00)/page '0'(0x20) reference 
85                  7.  bit 6 normal(0x00)/page 'nnn'(0x40) reference 
86                  8.  bit  7  LSB  byte(0x00)/MSB  byte(0x80) with 2-byte
87                      mode 
88
89              2.  n2  is  a byte index into the corresponding (i.e.  pre-
90                  ceeding) T line data (i.e.  a pointer to the data to be
91                  updated  by  the  relocation).   The T line data may be
92                  1-byte or  2-byte  byte  data  format  or  2-byte  word
93                  format.  
94
95              3.  xx xx  is the area/symbol index for the area/symbol be-
96                  ing referenced.  the corresponding area/symbol is found
97                  in the header area/symbol lists.  
98
99
100         The groups of 4 bytes are repeated for each item requiring relo-
101         cation in the preceeding T line.  
102
103
104         2.5.8  P Line 
105
106                 P 0 0 nn nn n1 n2 xx xx 
107
108            The  P  line provides the paging information to the linker as
109         specified by a .setdp directive.  The format of  the  relocation
110         information is identical to that of the R line.  The correspond-
111         ing T line has the following information:  
112                 T xx xx aa aa bb bb 
113
114            Where  aa aa is the area reference number which specifies the
115         selected page area and bb bb is the base address  of  the  page.
116         bb bb will require relocation processing if the 'n1 n2 xx xx' is
117         specified in the P line.  The linker will verify that  the  base
118         address is on a 256 byte boundary and that the page length of an
119         area defined with the PAG type is not larger than 256 bytes.  
120
121            The  linker  defaults any direct page references to the first
122         area defined in the input REL file.  All ASxxxx assemblers  will
123         specify the _CODE area first, making this the default page area.