]> git.sur5r.net Git - cc65/blob - include/o65.h
Fixes for the watcom makefiles:
[cc65] / include / o65.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                   o65.h                                   */
4 /*                                                                           */
5 /*                    Definitions for the o65 file format                    */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2002-2005 Ullrich von Bassewitz                                       */
10 /*               Römerstrasse 52                                             */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
15 /* This software is provided 'as-is', without any expressed or implied       */
16 /* warranty.  In no event will the authors be held liable for any damages    */
17 /* arising from the use of this software.                                    */
18 /*                                                                           */
19 /* Permission is granted to anyone to use this software for any purpose,     */
20 /* including commercial applications, and to alter it and redistribute it    */
21 /* freely, subject to the following restrictions:                            */
22 /*                                                                           */
23 /* 1. The origin of this software must not be misrepresented; you must not   */
24 /*    claim that you wrote the original software. If you use this software   */
25 /*    in a product, an acknowledgment in the product documentation would be  */
26 /*    appreciated but is not required.                                       */
27 /* 2. Altered source versions must be plainly marked as such, and must not   */
28 /*    be misrepresented as being the original software.                      */
29 /* 3. This notice may not be removed or altered from any source              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 /* This files exports structures and constants to handle the o65 relocatable
37  * file format as defined by Andre Fachat. See the original document under
38  *
39  *      http://www.6502.org/users/andre/o65/fileformat.html
40  *
41  * for more information.
42  */
43
44
45
46 #ifndef _O65_H
47 #define _O65_H
48
49
50
51 /* o65 size type. It is 2 bytes for the 6502 and 4 bytes for the 65816 */
52 typedef unsigned o65_size;
53
54
55 /* Structure that defines the o65 file header */
56 typedef struct o65_header o65_header;
57 struct o65_header {
58     char        marker[2];      /* Non-C64 marker */
59     char        magic[3];       /* o65 magic */
60     char        version;        /* Version number */
61     unsigned    mode;           /* Mode word */
62     o65_size    tbase;          /* Original text (code) segment address */
63     o65_size    tlen;           /* Size of text (code) segment */
64     o65_size    dbase;          /* Original data segment address */
65     o65_size    dlen;           /* Size of data segment */
66     o65_size    bbase;          /* Original bss segment address */
67     o65_size    blen;           /* Size of bss segment */
68     o65_size    zbase;          /* Original zp segment address */
69     o65_size    zlen;           /* Size of zp segment */
70     o65_size    stack;          /* Stacksize needed */
71 };
72
73
74
75 /* Marker, magic and version number */
76 #define O65_MARKER_0            0x01
77 #define O65_MARKER_1            0x00
78 #define O65_MAGIC_0             0x6F    /* 'o' */
79 #define O65_MAGIC_1             0x36    /* '6' */
80 #define O65_MAGIC_2             0x35    /* '5' */
81 #define O65_VERSION             0x00
82
83 /* Defines for the mode word */
84 #define O65_CPU_65816           0x8000  /* Executable is for 65816 */
85 #define O65_CPU_6502            0x0000  /* Executable is for the 6502 */
86 #define O65_CPU_MASK            0x8000  /* Mask to extract CPU type */
87
88 #define O65_RELOC_PAGE          0x4000  /* Page wise relocation */
89 #define O65_RELOC_BYTE          0x0000  /* Byte wise relocation */
90 #define O65_RELOC_MASK          0x4000  /* Mask to extract relocation type */
91
92 #define O65_SIZE_32BIT          0x2000  /* All size words are 32bit */
93 #define O65_SIZE_16BIT          0x0000  /* All size words are 16bit */
94 #define O65_SIZE_MASK           0x2000  /* Mask to extract size */
95
96 #define O65_FTYPE_OBJ           0x1000  /* Object file */
97 #define O65_FTYPE_EXE           0x0000  /* Executable file */
98 #define O65_FTYPE_MASK          0x1000  /* Mask to extract type */
99
100 #define O65_ADDR_SIMPLE         0x0800  /* Simple addressing */
101 #define O65_ADDR_DEFAULT        0x0000  /* Default addressing */
102 #define O65_ADDR_MASK           0x0800  /* Mask to extract addressing */
103
104 #define O65_ALIGN_1             0x0000  /* Bytewise alignment */
105 #define O65_ALIGN_2             0x0001  /* Align words */
106 #define O65_ALIGN_4             0x0002  /* Align longwords */
107 #define O65_ALIGN_256           0x0003  /* Align pages (256 bytes) */
108 #define O65_ALIGN_MASK          0x0003  /* Mask to extract alignment */
109
110 /* The mode word as generated by the ld65 linker */
111 #define O65_MODE_CC65           (O65_CPU_6502    |      \
112                                  O65_RELOC_BYTE  |      \
113                                  O65_SIZE_16BIT  |      \
114                                  O65_FTYPE_EXE   |      \
115                                  O65_ADDR_SIMPLE |      \
116                                  O65_ALIGN_1)
117
118 /* The four o65 segment types. */
119 #define O65_SEGID_UNDEF         0x00
120 #define O65_SEGID_ABS           0x01
121 #define O65_SEGID_TEXT          0x02
122 #define O65_SEGID_DATA          0x03
123 #define O65_SEGID_BSS           0x04
124 #define O65_SEGID_ZP            0x05
125 #define O65_SEGID_MASK          0x07
126
127 /* Relocation type codes */
128 #define O65_RTYPE_WORD          0x80
129 #define O65_RTYPE_HIGH          0x40
130 #define O65_RTYPE_LOW           0x20
131 #define O65_RTYPE_SEGADDR       0xC0
132 #define O65_RTYPE_SEG           0xA0
133 #define O65_RTYPE_MASK          0xE0
134
135 /* Segment IDs */
136 #define O65_SEGID_UNDEF         0x00
137 #define O65_SEGID_ABS           0x01
138 #define O65_SEGID_TEXT          0x02
139 #define O65_SEGID_DATA          0x03
140 #define O65_SEGID_BSS           0x04
141 #define O65_SEGID_ZP            0x05
142 #define O65_SEGID_MASK          0x07
143
144 /* Option tags */
145 #define O65_OPT_FILENAME        0
146 #define O65_OPT_OS              1
147 #define O65_OPT_ASM             2
148 #define O65_OPT_AUTHOR          3
149 #define O65_OPT_TIMESTAMP       4
150
151 /* Operating system codes for O65_OPT_OS */
152 #define O65_OS_OSA65            1
153 #define O65_OS_LUNIX            2
154 #define O65_OS_CC65             3
155 #define O65_OS_OPENCBM          4
156
157
158
159 /* End of o65.h */
160 #endif
161
162
163