shithub: spirva

Download patch

ref: a0d30aba763788d63e47878756cbd4e5cc6f6798
parent: ca99199e72dc182d2801eb591cdf470c707c1e6c
author: sirjofri <sirjofri@sirjofri.de>
date: Sun Feb 18 05:36:58 EST 2024

use keyword lookup, fixes strings

--- a/asm.c
+++ b/asm.c
@@ -7,13 +7,18 @@
 
 #define NIL 0
 
-#define BUF4(x) ((x)%4 ? ((x)/4 + 1)*4 : (x))
-
 Inst res;
 Inst op;
 Inst args[10];
 int argptr = 0;
 
+int
+lstrlen(int len)
+{
+	int nlen = len + 1;
+	return (nlen)%4 == 0 ? (nlen/4) : (nlen/4)+1;
+}
+
 void
 a_init()
 {
@@ -122,9 +127,9 @@
 			break;
 		case STR:
 			slen = strlen(in.str);
-			memset(optr, 0, BUF4(slen));
+			memset(optr, 0, lstrlen(slen)*4);
 			memcpy(optr, in.str, slen);
-			optr += slen/4+1;
+			optr += lstrlen(slen);
 			break;
 		}
 	}
@@ -199,6 +204,6 @@
 {
 	Inst a;
 	a.type = INT;
-	a.i = 0;
+	a.i = k_lookup(str);
 	arg(a);
 }