]> git.sur5r.net Git - cc65/blob - asminc/o65.inc
goto.c warning fix for implicit truncation
[cc65] / asminc / o65.inc
1 ;*****************************************************************************/
2 ;*                                                                           */
3 ;*                                  o65.inc                                  */
4 ;*                                                                           */
5 ;*                    Definitions for the o65 file format                    */
6 ;*                                                                           */
7 ;*                                                                           */
8 ;*                                                                           */
9 ;* (C) 2002-2009, Ullrich von Bassewitz                                      */
10 ;*                Roemerstrasse 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.
38
39
40
41 ; The o65 header structure (6502 format)
42 .struct O65_HDR
43         MARKER          .byte   2       ; Non-C64 marker: $01 $00
44         MAGIC           .byte   3       ; o65 magic: "o65"
45         VERSION         .byte   1       ; Version number
46         MODE            .word           ; Mode word
47         TBASE           .word           ; Original text (code) segment address
48         TLEN            .word           ; Size of text (code) segment
49         DBASE           .word           ; Original data segment address
50         DLEN            .word           ; Size of data segment
51         BBASE           .word           ; Original bss segment address
52         BLEN            .word           ; Size of bss segment
53         ZBASE           .word           ; Original zp segment address
54         ZLEN            .word           ; Size of zp segment
55         STACK           .word           ; Stacksize needed
56 .endstruct
57
58 ; Marker, magic and version number
59 O65_MARKER_0            =       $01
60 O65_MARKER_1            =       $00
61 O65_MAGIC_0             =       $6F     ; 'o'
62 O65_MAGIC_1             =       $36     ; '6'
63 O65_MAGIC_2             =       $35     ; '5'
64 O65_VERSION             =       $00
65
66 ; Defines for the mode word
67 O65_CPU_65816           =       $8000   ; Executable is for 65816
68 O65_CPU_6502            =       $0000   ; Executable is for the 6502
69 O65_CPU_MASK            =       $8000   ; Mask to extract CPU type
70
71 O65_RELOC_PAGE          =       $4000   ; Page wise relocation
72 O65_RELOC_BYTE          =       $0000   ; Byte wise relocation
73 O65_RELOC_MASK          =       $4000   ; Mask to extract relocation type
74
75 O65_SIZE_32BIT          =       $2000   ; All size words are 32bit
76 O65_SIZE_16BIT          =       $0000   ; All size words are 16bit
77 O65_SIZE_MASK           =       $2000   ; Mask to extract size
78
79 O65_FTYPE_OBJ           =       $1000   ; Object file
80 O65_FTYPE_EXE           =       $0000   ; Executable file
81 O65_FTYPE_MASK          =       $1000   ; Mask to extract type
82
83 O65_ADDR_SIMPLE         =       $0800   ; Simple addressing
84 O65_ADDR_DEFAULT        =       $0000   ; Default addressing
85 O65_ADDR_MASK           =       $0800   ; Mask to extract addressing
86
87 O65_CHAIN               =       $0400   ; Chained file, another one follows
88 O65_CHAIN_MASK          =       $0400   ; Mask to extract chain flag
89
90 O65_BSSZERO             =       $0200   ; BSS segment must be zeroed
91 O65_BSSZERO_MASK        =       $0200   ; Mask to extract bss zero flag
92
93 ; The following is used if O65_CPU == 6502
94 O65_CPU2_6502           =       $0000   ; Executable is for 6502
95 O65_CPU2_65C02          =       $0010   ; Executable is for 65C02
96 O65_CPU2_65SC02         =       $0020   ; Executable is for 65SC02
97 O65_CPU2_65CE02         =       $0030   ; Executable is for 65CE02
98 O65_CPU2_6502X          =       $0040   ; Executable is for NMOS 6502
99 O65_CPU2_65816_EMU      =       $0050   ; Executable is for 65816 in emul mode
100 O65_CPU2_MASK           =       $00F0   ; Mask to extract CPU2 field
101
102 O65_ALIGN_1             =       $0000   ; Bytewise alignment
103 O65_ALIGN_2             =       $0001   ; Align words
104 O65_ALIGN_4             =       $0002   ; Align longwords
105 O65_ALIGN_256           =       $0003   ; Align pages (256 bytes)
106 O65_ALIGN_MASK          =       $0003   ; Mask to extract alignment
107
108 ; The mode word as generated by the ld65 linker
109 O65_MODE_CC65           = O65_CPU_6502 | O65_RELOC_BYTE | O65_SIZE_16BIT | O65_FTYPE_EXE | O65_ADDR_SIMPLE | O65_ALIGN_1
110
111 ; Relocation type codes
112 O65_RTYPE_WORD          =       $80
113 O65_RTYPE_HIGH          =       $40
114 O65_RTYPE_LOW           =       $20
115 O65_RTYPE_SEGADDR       =       $C0
116 O65_RTYPE_SEG           =       $A0
117 O65_RTYPE_MASK          =       $E0
118
119 ; Segment IDs
120 O65_SEGID_UNDEF         =       $00
121 O65_SEGID_ABS           =       $01
122 O65_SEGID_TEXT          =       $02
123 O65_SEGID_DATA          =       $03
124 O65_SEGID_BSS           =       $04
125 O65_SEGID_ZP            =       $05
126 O65_SEGID_MASK          =       $07
127
128 ; Option tags
129 O65_OPT_FILENAME        =       0
130 O65_OPT_OS              =       1
131 O65_OPT_ASM             =       2
132 O65_OPT_AUTHOR          =       3
133 O65_OPT_TIMESTAMP       =       4
134
135 ; Operating system codes for O65_OPT_OS
136 O65_OS_OSA65            =       1
137 O65_OS_LUNIX            =       2
138 O65_OS_CC65             =       3
139 O65_OS_OPENCBM          =       4
140
141 ; Load errors
142 O65_LOAD_OK             =       0       ; Module load successful
143 O65_LOAD_ERR_READ       =       1       ; Read error
144 O65_LOAD_ERR_HDR        =       2       ; Header error
145 O65_LOAD_ERR_OS         =       3       ; Wrong OS
146 O65_LOAD_ERR_FMT        =       4       ; Data format error
147 O65_LOAD_ERR_MEM        =       5       ; Not enough memory
148
149
150