---------------------------------------------------------------------------
</verb></tscreen>
-
+
<sect1>Command line options in detail<p>
Here is a description of all the command line options:
See: <tt><ref id=".XMATCH" name=".XMATCH"></tt>
+<sect1><tt>.MAX</tt><label id=".MAX"><p>
+
+ Builtin function. The result is the larger of two values.
+
+ The syntax is
+
+ <tscreen><verb>
+ .MAX (<value #1>, <value #2>)
+ </verb></tscreen>
+
+ Example:
+
+ <tscreen><verb>
+ ; Reserve space for the larger of two data blocks
+ savearea: .max (.sizeof (foo), .sizeof (bar))
+ </verb></tscreen>
+
+ See: <tt><ref id=".MIN" name=".MIN"></tt>
+
+
<sect1><tt>.MID</tt><label id=".MID"><p>
Builtin function. Takes a starting index, a count and a token list as
name=".RIGHT"></tt> builtin functions.
+<sect1><tt>.MIN</tt><label id=".MIN"><p>
+
+ Builtin function. The result is the smaller of two values.
+
+ The syntax is
+
+ <tscreen><verb>
+ .MIN (<value #1>, <value #2>)
+ </verb></tscreen>
+
+ Example:
+
+ <tscreen><verb>
+ ; Reserve space for some data, but 256 bytes minimum
+ savearea: .min (.sizeof (foo), 256)
+ </verb></tscreen>
+
+ See: <tt><ref id=".MAX" name=".MAX"></tt>
+
+
<sect1><tt>.REF, .REFERENCED</tt><label id=".REFERENCED"><p>
Builtin function. The function expects an identifier as argument in braces.
/* */
/* */
/* */
-/* (C) 1998-2009, Ullrich von Bassewitz */
+/* (C) 1998-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
+static ExprNode* FuncMax (void)
+/* Handle the .MAX function */
+{
+ ExprNode* Left;
+ ExprNode* Right;
+ ExprNode* Expr;
+ long LeftVal, RightVal;
+
+ /* Two arguments to the pseudo function */
+ Left = Expression ();
+ ConsumeComma ();
+ Right = Expression ();
+
+ /* Check if we can evaluate the value immediately */
+ if (IsEasyConst (Left, &LeftVal) && IsEasyConst (Right, &RightVal)) {
+ FreeExpr (Left);
+ FreeExpr (Right);
+ Expr = GenLiteralExpr ((LeftVal > RightVal)? LeftVal : RightVal);
+ } else {
+ /* Make an expression node */
+ Expr = NewExprNode (EXPR_MAX);
+ Expr->Left = Left;
+ Expr->Right = Right;
+ }
+ return Expr;
+}
+
+
+
+static ExprNode* FuncMin (void)
+/* Handle the .MIN function */
+{
+ ExprNode* Left;
+ ExprNode* Right;
+ ExprNode* Expr;
+ long LeftVal, RightVal;
+
+ /* Two arguments to the pseudo function */
+ Left = Expression ();
+ ConsumeComma ();
+ Right = Expression ();
+
+ /* Check if we can evaluate the value immediately */
+ if (IsEasyConst (Left, &LeftVal) && IsEasyConst (Right, &RightVal)) {
+ FreeExpr (Left);
+ FreeExpr (Right);
+ Expr = GenLiteralExpr ((LeftVal < RightVal)? LeftVal : RightVal);
+ } else {
+ /* Make an expression node */
+ Expr = NewExprNode (EXPR_MIN);
+ Expr->Left = Left;
+ Expr->Right = Right;
+ }
+ return Expr;
+}
+
+
+
static ExprNode* FuncReferenced (void)
/* Handle the .REFERENCED builtin function */
{
N = Function (FuncMatch);
break;
+ case TOK_MAX:
+ N = Function (FuncMax);
+ break;
+
+ case TOK_MIN:
+ N = Function (FuncMin);
+ break;
+
case TOK_REFERENCED:
N = Function (FuncReferenced);
break;
{ ccNone, DoMacPack },
{ ccNone, DoMacro },
{ ccNone, DoUnexpected }, /* .MATCH */
+ { ccNone, DoUnexpected }, /* .MAX */
{ ccNone, DoInvalid }, /* .MID */
- { ccNone, DoNull },
+ { ccNone, DoUnexpected }, /* .MIN */
+ { ccNone, DoNull },
{ ccNone, DoOrg },
{ ccNone, DoOut },
{ ccNone, DoP02 },
{ ".MACPACK", TOK_MACPACK },
{ ".MACRO", TOK_MACRO },
{ ".MATCH", TOK_MATCH },
+ { ".MAX", TOK_MAX },
{ ".MID", TOK_MID },
+ { ".MIN", TOK_MIN },
{ ".MOD", TOK_MOD },
{ ".NOT", TOK_BOOLNOT },
{ ".NULL", TOK_NULL },
ED_Done (&Right);
}
-
+
static void StudyLiteral (ExprNode* Expr, ExprDesc* D)
/* Study a literal expression node */
+static void StudyMax (ExprNode* Expr, ExprDesc* D)
+/* Study an MAX binary expression node */
+{
+ /* Use helper function */
+ StudyBinaryExpr (Expr, D);
+
+ /* If the result is valid, apply the operation */
+ if (ED_IsValid (D)) {
+ D->Val = (D->Val > D->Right)? D->Val : D->Right;
+ }
+}
+
+
+
+static void StudyMin (ExprNode* Expr, ExprDesc* D)
+/* Study an MIN binary expression node */
+{
+ /* Use helper function */
+ StudyBinaryExpr (Expr, D);
+
+ /* If the result is valid, apply the operation */
+ if (ED_IsValid (D)) {
+ D->Val = (D->Val < D->Right)? D->Val : D->Right;
+ }
+}
+
+
+
static void StudyUnaryMinus (ExprNode* Expr, ExprDesc* D)
/* Study an EXPR_UNARY_MINUS expression node */
{
StudyBoolXor (Expr, D);
break;
+ case EXPR_MAX:
+ StudyMax (Expr, D);
+ break;
+
+ case EXPR_MIN:
+ StudyMin (Expr, D);
+ break;
+
case EXPR_UNARY_MINUS:
StudyUnaryMinus (Expr, D);
break;
*/
if (D->AddrSize == ADDR_SIZE_DEFAULT && ED_IsConst (D)) {
D->AddrSize = GetConstAddrSize (D->Val);
- }
+ }
/* If the expression is valid, throw away the address size and recalculate
* it using the data we have. This is more exact than the on-the-fly
TOK_MACPACK,
TOK_MACRO,
TOK_MATCH,
+ TOK_MAX,
TOK_MID,
+ TOK_MIN,
TOK_NULL,
TOK_ORG,
TOK_OUT,
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
printf (" BOOL_XOR");
break;
+ case EXPR_MAX:
+ printf (" MAX");
+ break;
+
+ case EXPR_MIN:
+ printf (" MIN");
+ break;
+
case EXPR_UNARY_MINUS:
printf (" NEG");
break;
/* */
/* */
/* */
-/* (C) 1998-2007 Ullrich von Bassewitz */
-/* Roemerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
#define EXPR_BOOLAND (EXPR_BINARYNODE | 0x11)
#define EXPR_BOOLOR (EXPR_BINARYNODE | 0x12)
#define EXPR_BOOLXOR (EXPR_BINARYNODE | 0x13)
+#define EXPR_MAX (EXPR_BINARYNODE | 0x14)
+#define EXPR_MIN (EXPR_BINARYNODE | 0x15)
/* Unary operations, right hand side is empty */
#define EXPR_UNARY_MINUS (EXPR_UNARYNODE | 0x01)
/*****************************************************************************/
/* */
-/* objdefs.h */
+/* objdefs.h */
/* */
/* Object file definitions */
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/* Defines for magic and version */
#define OBJ_MAGIC 0x616E7A55
-#define OBJ_VERSION 0x000B
+#define OBJ_VERSION 0x000C
/* Size of an object file header */
#define OBJ_HDR_SIZE (22*4)
case EXPR_BOOLXOR:
return (GetExprVal (Expr->Left) != 0) ^ (GetExprVal (Expr->Right) != 0);
+
+ case EXPR_MAX:
+ Left = GetExprVal (Expr->Left);
+ Right = GetExprVal (Expr->Right);
+ return (Left > Right)? Left : Right;
+
+ case EXPR_MIN:
+ Left = GetExprVal (Expr->Left);
+ Right = GetExprVal (Expr->Right);
+ return (Left < Right)? Left : Right;
case EXPR_UNARY_MINUS:
return -GetExprVal (Expr->Left);
-
-
-
-
-
-
-
-
-
-
-
-
-
-