From: Lukas Krickl Date: Wed, 3 Jan 2024 20:16:35 +0000 (+0100) Subject: Increased max macro parameters to 15 X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=24d6839d73add467d93ca0c3e0256c0352155660;p=ulas%2F.git Increased max macro parameters to 15 --- 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 ec638b9..b9eeb83 100644 Binary files a/tests/t0.bin and b/tests/t0.bin differ 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