1
0
mirror of https://github.com/cc65/cc65.git synced 2025-08-10 20:25:20 +00:00

Temp fix for some address size problems

git-svn-id: svn://svn.cc65.org/cc65/trunk@2674 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-11-18 20:50:55 +00:00
parent aa7b723b15
commit cd918a387c
4 changed files with 28 additions and 6 deletions

View File

@@ -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 */

View File

@@ -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.

View File

@@ -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;

View File

@@ -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);
}