X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=include%2Fo65.h;h=a50bf2fdde04b2d701304b5cc215683992c92450;hb=95b791bf0e22b154e631de7da8b625f952e2c1c2;hp=9674a590f69dae23f2d40724ef1fb04914df97dc;hpb=cc80937c3b3fedb80cd76b8a7b6bdc341a38cadf;p=cc65 diff --git a/include/o65.h b/include/o65.h index 9674a590f..a50bf2fdd 100644 --- a/include/o65.h +++ b/include/o65.h @@ -1,15 +1,15 @@ /*****************************************************************************/ /* */ -/* o65.h */ +/* o65.h */ /* */ -/* Definitions for the o65 file format */ +/* Definitions for the o65 file format */ /* */ /* */ /* */ -/* (C) 2002 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2002-2009, Ullrich von Bassewitz */ +/* Roemerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -34,12 +34,12 @@ /* This files exports structures and constants to handle the o65 relocatable - * file format as defined by Andre Fachat. See the original document under - * - * http://www.6502.org/users/andre/o65/fileformat.html - * - * for more information. - */ +** file format as defined by Andre Fachat. See the original document under +** +** http://www.6502.org/users/andre/o65/fileformat.html +** +** for more information. +*/ @@ -52,14 +52,14 @@ typedef unsigned o65_size; -/* Define a structure with the sid register offsets */ +/* Structure that defines the o65 file header */ typedef struct o65_header o65_header; struct o65_header { char marker[2]; /* Non-C64 marker */ char magic[3]; /* o65 magic */ - char version; /* Version number */ + char version; /* Version number */ unsigned mode; /* Mode word */ - o65_size tbase; /* Original text (code) segment address */ + o65_size tbase; /* Original text (code) segment address */ o65_size tlen; /* Size of text (code) segment */ o65_size dbase; /* Original data segment address */ o65_size dlen; /* Size of data segment */ @@ -72,8 +72,16 @@ struct o65_header { +/* Marker, magic and version number */ +#define O65_MARKER_0 0x01 +#define O65_MARKER_1 0x00 +#define O65_MAGIC_0 0x6F /* 'o' */ +#define O65_MAGIC_1 0x36 /* '6' */ +#define O65_MAGIC_2 0x35 /* '5' */ +#define O65_VERSION 0x00 + /* Defines for the mode word */ -#define O65_CPU_65816 0x8000 /* Executable is for 65816 */ +#define O65_CPU_65816 0x8000 /* Executable is for 65816 */ #define O65_CPU_6502 0x0000 /* Executable is for the 6502 */ #define O65_CPU_MASK 0x8000 /* Mask to extract CPU type */ @@ -81,23 +89,55 @@ struct o65_header { #define O65_RELOC_BYTE 0x0000 /* Byte wise relocation */ #define O65_RELOC_MASK 0x4000 /* Mask to extract relocation type */ -#define O65_SIZE_32BIT 0x2000 /* All size words are 32bit */ +#define O65_SIZE_32BIT 0x2000 /* All size words are 32bit */ #define O65_SIZE_16BIT 0x0000 /* All size words are 16bit */ #define O65_SIZE_MASK 0x2000 /* Mask to extract size */ +#define O65_FTYPE_OBJ 0x1000 /* Object file */ +#define O65_FTYPE_EXE 0x0000 /* Executable file */ +#define O65_FTYPE_MASK 0x1000 /* Mask to extract type */ + +#define O65_ADDR_SIMPLE 0x0800 /* Simple addressing */ +#define O65_ADDR_DEFAULT 0x0000 /* Default addressing */ +#define O65_ADDR_MASK 0x0800 /* Mask to extract addressing */ + +#define O65_CHAIN 0x0400 /* Chained file, another one follows */ +#define O65_CHAIN_MASK 0x0400 /* Mask to extract chain flag */ + +#define O65_BSSZERO 0x0200 /* BSS segment must be zeroed */ +#define O65_BSSZERO_MASK 0x0200 /* Mask to extract bss zero flag */ + +/* The following is used if O65_CPU == 6502 */ +#define O65_CPU2_6502 0x0000 /* Executable is for 6502 */ +#define O65_CPU2_65C02 0x0010 /* Executable is for 65C02 */ +#define O65_CPU2_65SC02 0x0020 /* Executable is for 65SC02 */ +#define O65_CPU2_65CE02 0x0030 /* Executable is for 65CE02 */ +#define O65_CPU2_6502X 0x0040 /* Executable is for NMOS 6502 */ +#define O65_CPU2_65816_EMU 0x0050 /* Executable is for 65816 in emul mode */ +#define O65_CPU2_MASK 0x00F0 /* Mask to extract CPU2 field */ + #define O65_ALIGN_1 0x0000 /* Bytewise alignment */ #define O65_ALIGN_2 0x0001 /* Align words */ #define O65_ALIGN_4 0x0002 /* Align longwords */ #define O65_ALIGN_256 0x0003 /* Align pages (256 bytes) */ #define O65_ALIGN_MASK 0x0003 /* Mask to extract alignment */ +/* The mode word as generated by the ld65 linker */ +#define O65_MODE_CC65 (O65_CPU_6502 | \ + O65_RELOC_BYTE | \ + O65_SIZE_16BIT | \ + O65_FTYPE_EXE | \ + O65_ADDR_SIMPLE | \ + O65_ALIGN_1) + /* The four o65 segment types. */ -#define O65_SEG_UNDEF 0x00 -#define O65_SEG_ABS 0x01 -#define O65_SEG_TEXT 0x02 -#define O65_SEG_DATA 0x03 -#define O65_SEG_BSS 0x04 -#define O65_SEG_ZP 0x05 +#define O65_SEGID_UNDEF 0x00 +#define O65_SEGID_ABS 0x01 +#define O65_SEGID_TEXT 0x02 +#define O65_SEGID_DATA 0x03 +#define O65_SEGID_BSS 0x04 +#define O65_SEGID_ZP 0x05 +#define O65_SEGID_MASK 0x07 /* Relocation type codes */ #define O65_RTYPE_WORD 0x80 @@ -118,15 +158,16 @@ struct o65_header { /* Option tags */ #define O65_OPT_FILENAME 0 -#define O65_OPT_OS 1 -#define O65_OPT_ASM 2 -#define O65_OPT_AUTHOR 3 -#define O65_OPT_TIMESTAMP 4 +#define O65_OPT_OS 1 +#define O65_OPT_ASM 2 +#define O65_OPT_AUTHOR 3 +#define O65_OPT_TIMESTAMP 4 /* Operating system codes for O65_OPT_OS */ -#define O65_OS_OSA65 1 -#define O65_OS_LUNIX 2 -#define O65_OS_CC65_MODULE 3 +#define O65_OS_OSA65 1 +#define O65_OS_LUNIX 2 +#define O65_OS_CC65 3 +#define O65_OS_OPENCBM 4