From 3107e20dba7ea8aaea51474e59dbac72097fb2d3 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 20 Nov 2023 15:58:24 +0100 Subject: [PATCH] WIP: instruction parsing --- src/test.c | 7 +++++++ src/ulas.c | 14 ++++++++++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/test.c b/src/test.c index dd76cd5..d1cce77 100644 --- a/src/test.c +++ b/src/test.c @@ -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(); diff --git a/src/ulas.c b/src/ulas.c index caa57b5..6f402f5 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -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: -- 2.30.2