From 29ed1fabefea98df845eba7b3fa0f1b7a8836000 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 3 Jan 2024 23:18:40 +0100 Subject: [PATCH] Fixed $10 - $15 macro args --- src/ulas.c | 11 ++++++++--- tests/t0.bin | Bin 207 -> 212 bytes tests/t0.s | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/ulas.c b/src/ulas.c index e856721..d74f8e5 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -408,8 +408,12 @@ int ulas_tok(struct ulas_str *dst, const char **out_line, unsigned long n) { ulas_strensr(dst, write + 2); // escape char tokens dst->buf[write++] = line[i++]; - if (line[i] && !isspace(line[i])) { + if (line[i] == '$') { dst->buf[write++] = line[i++]; + } else { + while (line[i] && isdigit(line[i])) { + dst->buf[write++] = line[i++]; + } } goto tokdone; case '=': @@ -774,7 +778,7 @@ char *ulas_preprocexpand(struct ulas_preproc *pp, const char *raw_line, // loop until 9 args are found or the line ends int paramc = 0; while (paramc < ULAS_MACROPARAMMAX && - // TODO: allow escaping , with \, + // TODO: allow escaping , with \, ulas_tokuntil(&pp->macroparam[paramc], ',', &praw_line, *n) > 0) { // trim new lines from the end of macro params @@ -785,7 +789,8 @@ char *ulas_preprocexpand(struct ulas_preproc *pp, const char *raw_line, ulas_strensr(&pp->line, strlen(def->value) + 2); const char *macro_argname[ULAS_MACROPARAMMAX] = { - "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11", "$12", "$13", "$14", "$15"}; + "$1", "$2", "$3", "$4", "$5", "$6", "$7", "$8", + "$9", "$10", "$11", "$12", "$13", "$14", "$15"}; const char *val = def->value; unsigned long vallen = strlen(def->value); diff --git a/tests/t0.bin b/tests/t0.bin index b9eeb83f33a9afa4220a1c8dbc765c563ffecaea..03c89e17a30fd94f49614a9effe6dfd1cd4a83a3 100644 GIT binary patch delta 15 WcmX@lc!hDo84ep;JNuH<;t~Kb5e2{i delta 10 Rcmcb@c%E^>8D=hS9sm}C1110f diff --git a/tests/t0.s b/tests/t0.s index 718063a..04c9609 100644 --- a/tests/t0.s +++ b/tests/t0.s @@ -135,10 +135,11 @@ l3: .db 1 .rep repc, 6, 1, ld a, repc #macro testmacro +.db $9 .db $10 .db $11 .db $12 .str $13 #endmacro -testmacro 1, 2, 3, 4, 5, 6, 7, 8, 9, 61, 62, 63, "test" +testmacro 1, 2, 3, 4, 5, 6, 7, 8, 60, 61, 62, 63, "test" -- 2.30.2