1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 20:29:34 +00:00

New function GenAddExpr

git-svn-id: svn://svn.cc65.org/cc65/trunk@2664 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-11-14 08:44:12 +00:00
parent ebd2336d2b
commit 742b1ffd8e
2 changed files with 16 additions and 3 deletions

View File

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

View File

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