From cd918a387c4b2fe2e4e607e50b63b08cf09f431b Mon Sep 17 00:00:00 2001 From: cuz Date: Tue, 18 Nov 2003 20:50:55 +0000 Subject: [PATCH] Temp fix for some address size problems git-svn-id: svn://svn.cc65.org/cc65/trunk@2674 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/expr.c | 14 +++++++++++--- src/ca65/expr.h | 5 ++++- src/ca65/scanner.c | 3 +++ src/ca65/symentry.c | 12 ++++++++++-- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 417632f09..3a13f4c8f 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -196,7 +196,15 @@ int IsByteRange (long Val) int IsWordRange (long Val) /* Return true if this is a word value */ { - return (Val & ~0xFFFF) == 0; + return (Val & ~0xFFFFL) == 0; +} + + + +int IsFarRange (long Val) +/* Return true if this is a far (24 bit) value */ +{ + return (Val & ~0xFFFFFFL) == 0; } @@ -276,7 +284,7 @@ static ExprNode* FuncConst (void) /* Done */ return Result; -} +} @@ -403,7 +411,7 @@ static ExprNode* FuncReferenced (void) static ExprNode* FuncSizeOf (void) /* Handle the .SIZEOF function */ -{ +{ long Size; /* Get the struct for the scoped struct name */ diff --git a/src/ca65/expr.h b/src/ca65/expr.h index d7b046f62..a3827e873 100644 --- a/src/ca65/expr.h +++ b/src/ca65/expr.h @@ -66,7 +66,7 @@ void FreeExpr (ExprNode* Root); ExprNode* SimplifyExpr (ExprNode* Expr); /* Try to simplify the given expression tree */ -ExprNode* GenLiteralExpr (long Val); +ExprNode* GenLiteralExpr (long Val); /* Return an expression tree that encodes the given literal value */ ExprNode* GenSymExpr (struct SymEntry* Sym); @@ -113,6 +113,9 @@ int IsByteRange (long Val); int IsWordRange (long Val); /* Return true if this is a word value */ +int IsFarRange (long Val); +/* Return true if this is a far (24 bit) value */ + ExprNode* CloneExpr (ExprNode* Expr); /* Clone the given expression tree. The function will simply clone symbol * nodes, it will not resolve them. diff --git a/src/ca65/scanner.c b/src/ca65/scanner.c index cb4712a65..56aadd74c 100644 --- a/src/ca65/scanner.c +++ b/src/ca65/scanner.c @@ -1152,6 +1152,7 @@ unsigned char ParseAddrSize (void) "DIRECT", "ZEROPAGE", "ZP", "ABSOLUTE", "ABS", "NEAR", "FAR", + "LONG", "DWORD", }; /* Check for an identifier */ @@ -1169,6 +1170,8 @@ unsigned char ParseAddrSize (void) case 4: case 5: return ADDR_SIZE_ABS; case 6: return ADDR_SIZE_FAR; + case 7: + case 8: return ADDR_SIZE_LONG; default: Error ("Address size specifier expected"); return ADDR_SIZE_DEFAULT; diff --git a/src/ca65/symentry.c b/src/ca65/symentry.c index a47fde9a6..6d3dbc30c 100644 --- a/src/ca65/symentry.c +++ b/src/ca65/symentry.c @@ -195,8 +195,16 @@ void SymDef (SymEntry* S, ExprNode* Expr, unsigned char AddrSize, unsigned Flags /* Map a default address size to a real value */ if (AddrSize == ADDR_SIZE_DEFAULT) { long Val; - if (IsConstExpr (Expr, &Val) && IsByteRange (Val)) { - AddrSize = ADDR_SIZE_ZP; + if (IsConstExpr (Expr, &Val)) { + if (IsByteRange (Val)) { + AddrSize = ADDR_SIZE_ZP; + } else if (IsWordRange (Val)) { + AddrSize = ADDR_SIZE_ABS; + } else if (IsFarRange (Val)) { + AddrSize = ADDR_SIZE_FAR; + } else { + AddrSize = ADDR_SIZE_LONG; + } } else { AddrSize = SymAddrSize (S); } -- 2.39.5