WIP: instruction parsing
authorLukas Krickl <lukas@krickl.dev>
Mon, 20 Nov 2023 14:58:24 +0000 (15:58 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 20 Nov 2023 14:58:24 +0000 (15:58 +0100)
src/test.c
src/ulas.c

index dd76cd5b53d5e6eeebd46cacb921ed6ad140008f..d1cce77f52cddb27af3f85447ee0d40c2ba04227 100644 (file)
@@ -276,6 +276,12 @@ void test_intexpr(void) {
   TESTEND("intexpr");
 }
 
+void test_asminstr(void) {
+  TESTBEGIN("asminstr");
+
+  TESTEND("asminstr");
+}
+
 int main(int arc, char **argv) {
   ulas_init(ulas_cfg_from_env());
 
@@ -288,6 +294,7 @@ int main(int arc, char **argv) {
   test_preproc();
   test_totok();
   test_intexpr();
+  test_asminstr();
 
   ulas_free();
 
index caa57b5394cc6b7d9b6941ecd78981e5d72759b3..6f402f57fd00bcb0314fafa0cec1a70fec12082a 100644 (file)
@@ -1014,7 +1014,7 @@ int ulas_tokexpr(const char **line, unsigned long n) {
       goto end;
     }
 
-    // empty tokens are going to be ignored 
+    // empty tokens are going to be ignored
     if (strnlen(ulas.tok.buf, ulas.tok.maxlen) == 0) {
       continue;
     }
@@ -1299,11 +1299,16 @@ int ulas_intexpr(const char **line, unsigned long n, int *rc) {
     return -1;
   }
 
-
   // execute the tree of expressions
   return ulas_intexpreval(expr, rc);
 }
 
+int ulas_asminstr(FILE *dst, const char *line, unsigned long n) {
+  int rc = 0;
+
+  return rc;
+}
+
 int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) {
   const char *start = line;
   int rc = 0;
@@ -1353,6 +1358,11 @@ int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) {
 
   } else {
     // is regular line in form of [label:] instruction ; comment
+    if (ulas_asminstr(dst, line, n) == -1) {
+      ULASERR("Unable to assemble instruction\n");
+      rc = -1;
+      goto fail;
+    }
   }
 
 fail: