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:
committed by
Oliver Schmidt
parent
a01c4231f2
commit
ac2ecb0b2c
@@ -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. */
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user