From 24d6839d73add467d93ca0c3e0256c0352155660 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 3 Jan 2024 21:16:35 +0100 Subject: [PATCH] Increased max macro parameters to 15 --- include/ulas.h | 2 +- src/ulas.c | 4 +++- tests/t0.bin | Bin 204 -> 207 bytes tests/t0.s | 8 ++++++++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/ulas.h b/include/ulas.h index b06e5fb..633a204 100644 --- a/include/ulas.h +++ b/include/ulas.h @@ -15,7 +15,7 @@ #define ULAS_PATHMAX 4096 #define ULAS_LINEMAX 4096 #define ULAS_OUTBUFMAX 64 -#define ULAS_MACROPARAMMAX 9 +#define ULAS_MACROPARAMMAX 15 #define MAX(x, y) (((x) > (y)) ? (x) : (y)) #define MIN(x, y) (((x) < (y)) ? (x) : (y)) diff --git a/src/ulas.c b/src/ulas.c index 8f03ed9..73e8c28 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -757,6 +757,7 @@ char *ulas_preprocexpand(struct ulas_preproc *pp, const char *raw_line, } case ULAS_PPMACRO: { // TODO: i am sure we can optimize the resize of line buffers here... + // TODO: allow recursive macro calls // get 9 comma separated values. // $1-$9 will reference the respective arg @@ -773,6 +774,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 \, ulas_tokuntil(&pp->macroparam[paramc], ',', &praw_line, *n) > 0) { // trim new lines from the end of macro params @@ -783,7 +785,7 @@ 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"}; + "$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 ec638b95dde8bd2d4f4eed37942e391c1444394a..b9eeb83f33a9afa4220a1c8dbc765c563ffecaea 100644 GIT binary patch delta 10 RcmX@Zc%E^>8D=hS9sm|H10DbX delta 6 NcmX@lc!qJp82}0d0{Q>| diff --git a/tests/t0.s b/tests/t0.s index 17e0ab0..0609ee7 100644 --- a/tests/t0.s +++ b/tests/t0.s @@ -133,3 +133,11 @@ l3: .db 1 .rep repc, 6, 2, ld a, repc .rep repc, 6, 1, ld a, repc + +#macro testmacro +.db $10 +.db $11 +.db $12 +#endmacro + +testmacro 1, 2, 3, 4, 5, 6, 7, 8, 9, 61, 62, 63 -- 2.30.2