diff --git a/src/ca65/expr.c b/src/ca65/expr.c index 9d4426191..b0eb0503c 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -1641,6 +1641,17 @@ static ExprNode* GenSectionExpr (unsigned SegNum) +ExprNode* GenAddExpr (ExprNode* Left, ExprNode* Right) +/* Generate an addition from the two operands */ +{ + ExprNode* Root = NewExprNode (EXPR_PLUS); + Root->Left = Left; + Root->Right = Right; + return Root; +} + + + ExprNode* GenCurrentPC (void) /* Return the current program counter as expression */ { @@ -1648,9 +1659,8 @@ ExprNode* GenCurrentPC (void) if (RelocMode) { /* Create SegmentBase + Offset */ - Root = NewExprNode (EXPR_PLUS); - Root->Left = GenSectionExpr (GetCurrentSegNum ()); - Root->Right = GenLiteralExpr (GetPC ()); + Root = GenAddExpr (GenSectionExpr (GetCurrentSegNum ()), + GenLiteralExpr (GetPC ())); } else { /* Absolute mode, just return PC value */ Root = GenLiteralExpr (GetPC ()); diff --git a/src/ca65/expr.h b/src/ca65/expr.h index 2edff0e1d..91ccbadb5 100644 --- a/src/ca65/expr.h +++ b/src/ca65/expr.h @@ -69,6 +69,9 @@ ExprNode* GenLiteralExpr (long Val); ExprNode* GenSymExpr (struct SymEntry* Sym); /* Return an expression node that encodes the given symbol */ +ExprNode* GenAddExpr (ExprNode* Left, ExprNode* Right); +/* Generate an addition from the two operands */ + ExprNode* GenCurrentPC (void); /* Return the current program counter as expression */