65816 now generate EXPR_NEARADDR instead of EXPR_WORD0 for default assumed address mode, which will be validated by the linker's range check rather than blindly truncated. Assuming the assembler correctly validated this, the linker is allowed to truncate.

This commit is contained in:
bbbradsmith
2019-05-01 02:12:03 -04:00
committed by Oliver Schmidt
parent a01c4231f2
commit ac2ecb0b2c
7 changed files with 61 additions and 3 deletions

View File

@@ -1865,6 +1865,28 @@ ExprNode* GenWordExpr (ExprNode* Expr)
ExprNode* GenNearAddrExpr (ExprNode* Expr)
/* A word sized expression that will error if given a far expression at assemble time. */
{
long Val;
/* Special handling for const expressions */
if (IsEasyConst (Expr, &Val)) {
FreeExpr (Expr);
Expr = GenLiteralExpr (Val & 0xFFFF);
if (Val > 0xFFFF)
{
Error("Range error: constant too large for assumed near address.");
}
} else {
ExprNode* Operand = Expr;
Expr = NewExprNode (EXPR_NEARADDR);
Expr->Left = Operand;
}
return Expr;
}
ExprNode* GenFarAddrExpr (ExprNode* Expr)
/* Force the given expression into a far address and return the result. */
{