shithub: rgbds

Download patch

ref: f29d768989cf23a2f77a3f6e018863c5e0b8ace0
parent: cc458a96937cc35abacb7c1b22654e194ac76b02
author: dbrotz <43593771+dbrotz@users.noreply.github.com>
date: Fri May 31 04:59:50 EDT 2019

Set all of expr struct's fields in mergetwoexpressions()

--- a/src/asm/rpn.c
+++ b/src/asm/rpn.c
@@ -32,6 +32,7 @@
 
 	uint32_t len = src1->nRPNLength + src2->nRPNLength;
 
+	expr->nVal = 0;
 	expr->tRPN = src1->tRPN;
 
 	if (src1->nRPNCapacity >= len) {
@@ -54,6 +55,7 @@
 	free(src2->tRPN);
 
 	expr->nRPNLength = len;
+	expr->nRPNOut = 0;
 	expr->isReloc = src1->isReloc || src2->isReloc;
 }
 
@@ -269,7 +271,7 @@
 		const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal == src2->nVal);
+	expr->nVal = (src1->nVal == src2->nVal);
 	pushbyte(expr, RPN_LOGEQ);
 }
 
@@ -277,7 +279,7 @@
 	       const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal > src2->nVal);
+	expr->nVal = (src1->nVal > src2->nVal);
 	pushbyte(expr, RPN_LOGGT);
 }
 
@@ -285,7 +287,7 @@
 	       const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal < src2->nVal);
+	expr->nVal = (src1->nVal < src2->nVal);
 	pushbyte(expr, RPN_LOGLT);
 }
 
@@ -293,7 +295,7 @@
 	       const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal >= src2->nVal);
+	expr->nVal = (src1->nVal >= src2->nVal);
 	pushbyte(expr, RPN_LOGGE);
 }
 
@@ -301,7 +303,7 @@
 	       const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal <= src2->nVal);
+	expr->nVal = (src1->nVal <= src2->nVal);
 	pushbyte(expr, RPN_LOGLE);
 }
 
@@ -309,7 +311,7 @@
 	       const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal != src2->nVal);
+	expr->nVal = (src1->nVal != src2->nVal);
 	pushbyte(expr, RPN_LOGNE);
 }
 
@@ -317,7 +319,7 @@
 	     const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal + src2->nVal);
+	expr->nVal = (src1->nVal + src2->nVal);
 	pushbyte(expr, RPN_ADD);
 }
 
@@ -325,7 +327,7 @@
 	     const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal - src2->nVal);
+	expr->nVal = (src1->nVal - src2->nVal);
 	pushbyte(expr, RPN_SUB);
 }
 
@@ -333,7 +335,7 @@
 	     const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal ^ src2->nVal);
+	expr->nVal = (src1->nVal ^ src2->nVal);
 	pushbyte(expr, RPN_XOR);
 }
 
@@ -341,7 +343,7 @@
 	    const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal | src2->nVal);
+	expr->nVal = (src1->nVal | src2->nVal);
 	pushbyte(expr, RPN_OR);
 }
 
@@ -349,7 +351,7 @@
 	     const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal & src2->nVal);
+	expr->nVal = (src1->nVal & src2->nVal);
 	pushbyte(expr, RPN_AND);
 }
 
@@ -366,7 +368,7 @@
 	else if (src2->nVal >= 32)
 		fatalerror("Shift by too big value: %d", src2->nVal);
 
-	expr->nVal = (expr->nVal << src2->nVal);
+	expr->nVal = (src1->nVal << src2->nVal);
 	pushbyte(expr, RPN_SHL);
 }
 
@@ -379,7 +381,7 @@
 	else if (src2->nVal >= 32)
 		fatalerror("Shift by too big value: %d", src2->nVal);
 
-	expr->nVal = (expr->nVal >> src2->nVal);
+	expr->nVal = (src1->nVal >> src2->nVal);
 	pushbyte(expr, RPN_SHR);
 }
 
@@ -387,7 +389,7 @@
 	     const struct Expression *src2)
 {
 	joinexpr();
-	expr->nVal = (expr->nVal * src2->nVal);
+	expr->nVal = (src1->nVal * src2->nVal);
 	pushbyte(expr, RPN_MUL);
 }
 
@@ -398,7 +400,7 @@
 	if (src2->nVal == 0)
 		fatalerror("Division by zero");
 
-	expr->nVal = (expr->nVal / src2->nVal);
+	expr->nVal = (src1->nVal / src2->nVal);
 	pushbyte(expr, RPN_DIV);
 }
 
@@ -409,7 +411,7 @@
 	if (src2->nVal == 0)
 		fatalerror("Division by zero");
 
-	expr->nVal = (expr->nVal % src2->nVal);
+	expr->nVal = (src1->nVal % src2->nVal);
 	pushbyte(expr, RPN_MOD);
 }