Extend the object code format by adding a (currently empty) scope table.

Use the address size for import, export and debug symbols (object code
change).
More changes to support the --memory-model switch and address sizes.


git-svn-id: svn://svn.cc65.org/cc65/trunk@2691 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-11-28 22:12:14 +00:00
parent e3eea961c2
commit 8f9a21ae3f
35 changed files with 589 additions and 254 deletions

View File

@@ -46,7 +46,7 @@
/* Defines for magic and version */
#define LIB_MAGIC 0x7A55616E
#define LIB_VERSION 0x000A
#define LIB_VERSION 0x000B
/* Size of an library file header */
#define LIB_HDR_SIZE 12

View File

@@ -36,6 +36,7 @@
#include <string.h>
/* common */
#include "addrsize.h"
#include "mmodel.h"
@@ -56,6 +57,11 @@ static const char* MemoryModelNames[MMODEL_COUNT] = {
"huge",
};
/* Address sizes for the segments */
unsigned char CodeAddrSize = ADDR_SIZE_ABS;
unsigned char DataAddrSize = ADDR_SIZE_ABS;
unsigned char ZpAddrSize = ADDR_SIZE_ZP;
/*****************************************************************************/
@@ -82,3 +88,41 @@ mmodel_t FindMemoryModel (const char* Name)
void SetMemoryModel (mmodel_t Model)
/* Set the memory model updating the MemoryModel variables and the address
* sizes for the segments.
*/
{
/* Remember the memory model */
MemoryModel = Model;
/* Set the address sizes for the segments */
switch (MemoryModel) {
case MMODEL_NEAR:
/* Code: near, data: near */
CodeAddrSize = ADDR_SIZE_ABS;
DataAddrSize = ADDR_SIZE_ABS;
break;
case MMODEL_FAR:
/* Code: far, data: near */
CodeAddrSize = ADDR_SIZE_FAR;
DataAddrSize = ADDR_SIZE_ABS;
break;
case MMODEL_HUGE:
/* Code: far, data: far */
CodeAddrSize = ADDR_SIZE_FAR;
DataAddrSize = ADDR_SIZE_FAR;
break;
default:
break;
}
/* Zeropage is always zeropage */
ZpAddrSize = ADDR_SIZE_ZP;
}

View File

@@ -56,8 +56,10 @@ typedef enum {
/* Memory model in use */
extern mmodel_t MemoryModel;
/* Address sizes for the segments */
extern unsigned char CodeAddrSize;
extern unsigned char DataAddrSize;
extern unsigned char ZpAddrSize;
@@ -70,6 +72,11 @@ extern mmodel_t MemoryModel;
mmodel_t FindMemoryModel (const char* Name);
/* Find a memory model by name. Return MMODEL_UNKNOWN for an unknown name. */
void SetMemoryModel (mmodel_t Model);
/* Set the memory model updating the MemoryModel variables and the address
* sizes for the segments.
*/
/* End of mmodel.h */

View File

@@ -7,7 +7,7 @@
/* */
/* */
/* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */
/* R<>merstra<EFBFBD>e 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
@@ -46,10 +46,10 @@
/* Defines for magic and version */
#define OBJ_MAGIC 0x616E7A55
#define OBJ_VERSION 0x000A
#define OBJ_VERSION 0x000B
/* Size of an object file header */
#define OBJ_HDR_SIZE (20*4)
#define OBJ_HDR_SIZE (22*4)
/* Flag bits */
#define OBJ_FLAGS_DBGINFO 0x0001 /* File has debug info */
@@ -80,6 +80,8 @@ struct ObjHeader {
unsigned long StrPoolSize; /* 32: Size of string pool */
unsigned long AssertOffs; /* 32: Offset to assertion table */
unsigned long AssertSize; /* 32: Size of assertion table */
unsigned long ScopeOffs; /* 32: Offset into scope table */
unsigned long ScopeSize; /* 32: Size of scope table */
};

View File

@@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstra<72>e 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -48,14 +48,6 @@
/* Import size */
#define IMP_ABS 0x00 /* Import as normal value */
#define IMP_ZP 0x01 /* Import as zero page symbol */
#define IMP_MASK_SIZE 0x01 /* Size mask */
#define IS_IMP_ABS(x) (((x) & IMP_MASK_SIZE) == IMP_ABS)
#define IS_IMP_ZP(x) (((x) & IMP_MASK_SIZE) == IMP_ZP)
/* Number of module constructor/destructor declarations for an export */
#define EXP_CONDES_MASK 0x07
@@ -63,14 +55,6 @@
#define GET_EXP_CONDES_COUNT(x) ((x) & EXP_CONDES_MASK)
#define INC_EXP_CONDES_COUNT(x) ((x)++)
/* Export size */
#define EXP_ABS 0x00 /* Export as normal value */
#define EXP_ZP 0x08 /* Export as zero page value */
#define EXP_MASK_SIZE 0x08 /* Size mask */
#define IS_EXP_ABS(x) (((x) & EXP_MASK_SIZE) == EXP_ABS)
#define IS_EXP_ZP(x) (((x) & EXP_MASK_SIZE) == EXP_ZP)
/* Export value type */
#define EXP_CONST 0x00 /* Mask bit for const values */
#define EXP_EXPR 0x10 /* Mask bit for expr values */