From 7338d820d45afffa841dced185116481d27bc76f Mon Sep 17 00:00:00 2001 From: qWord Date: Fri, 6 May 2016 18:32:43 +0200 Subject: [PATCH 1/2] Fix broken HIGHWORD-operator The HIGHWORD-Operator was implemented as right shift by 16 of opnd1->value. This is wrong because: - the bits 32...63 are not zeroed - the compiler might do an arithmetic shift (typeof opnd1->value == int_32) As fix, the result of the right shift is masked (bitwise AND) and then assigned to the 64 bit value opnd1->llvalue. Resolves: #152 resp. SF-BUG-298 --- expreval.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/expreval.c b/expreval.c index a07986c..96ee26a 100644 --- a/expreval.c +++ b/expreval.c @@ -1488,7 +1488,7 @@ static ret_code highword_op( int oper, struct expr *opnd1, struct expr *opnd2, s //opnd1->mem_type = MT_WORD; /* v2.05 */ opnd1->mem_type = MT_EMPTY; } - opnd1->value = opnd1->value >> 16; + opnd1->llvalue = (opnd1->value >> 16) & 0xffff; return( NOT_ERROR ); } From 33e0c070c79010d5027b43e6f91de07b888bc546 Mon Sep 17 00:00:00 2001 From: qWord Date: Fri, 6 May 2016 19:31:13 +0200 Subject: [PATCH 2/2] Reuse of equates in CreateVariable was erroneous If an equate already exist CreateVariable did not zero bits 32...63 of that equate. This cause that the predefined macros SIZESTR and INSTR return wrong values when the result-equate (for example) did contain negative values before macro invocation. Fixed by setting sym->value3264 to zero in case of reuse. Resolves: #156 resp. SF-BUG-303 --- equate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/equate.c b/equate.c index b4b4b61..4631cb1 100644 --- a/equate.c +++ b/equate.c @@ -317,6 +317,7 @@ struct asym *CreateVariable( const char *name, int value ) //sym->mem_type = MT_ABS; sym->variable = TRUE; sym->value = value; + sym->value3264 = 0; sym->isequate = TRUE; return( sym ); }