From: Lukas Krickl Date: Wed, 3 Jan 2024 22:18:40 +0000 (+0100) Subject: Fixed $10 - $15 macro args X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=29ed1fabefea98df845eba7b3fa0f1b7a8836000;p=ulas%2F.git Fixed $10 - $15 macro args --- 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 b9eeb83..03c89e1 100644 Binary files a/tests/t0.bin and b/tests/t0.bin differ 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"