From: cuz Date: Fri, 14 Nov 2003 08:44:12 +0000 (+0000) Subject: New function GenAddExpr X-Git-Tag: V2.12.0~1136 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=742b1ffd8eeedd5352ccb5025b7304ce6ae835ed;p=cc65 New function GenAddExpr git-svn-id: svn://svn.cc65.org/cc65/trunk@2664 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- 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 */