From 5cd635b43821e30aa7e7bb5f496e9a6690f3fa32 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 11 Dec 2023 21:20:11 +0100 Subject: [PATCH] Added .adv directive --- include/ulas.h | 4 ++++ src/ulas.c | 13 +++++++++++-- tests/t0.s | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/ulas.h b/include/ulas.h index e220cf6..4c65f03 100644 --- a/include/ulas.h +++ b/include/ulas.h @@ -45,6 +45,7 @@ #define ULAS_ASMSTR_INCBIN ".incbin" #define ULAS_ASMSTR_DEF ".def" #define ULAS_ASMSTR_CHKSM ".chksm" +#define ULAS_ASMSTR_ADV ".adv" // configurable tokens #define ULAS_TOK_COMMENT ';' @@ -370,6 +371,9 @@ enum ulas_asmdir { ULAS_ASMDIR_DEF, // inserts checksum into rom ULAS_ASMDIR_CHKSM, + // .adv + // advance .org by n bytes without writing to rom + ULAS_ASMDIR_ADV, }; // amount of registers diff --git a/src/ulas.c b/src/ulas.c index 666de32..0117150 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -2399,6 +2399,12 @@ int ulas_asmdirincbin(FILE *dst, const char **line, unsigned long n, int *rc) { return written; } +int ulas_asmdiradv(FILE *dst, const char **line, unsigned long n, int *rc) { + ULAS_EVALEXPRS(ulas.address += + ulas_intexpr(line, strnlen(*line, n), rc)); + return 0; +} + int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) { // this buffer is written both to dst and to verbose output char outbuf[ULAS_OUTBUFMAX]; @@ -2437,11 +2443,11 @@ int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) { ULAS_ASMSTR_BYTE, ULAS_ASMSTR_STR, ULAS_ASMSTR_FILL, ULAS_ASMSTR_PAD, ULAS_ASMSTR_INCBIN, ULAS_ASMSTR_DEF, - ULAS_ASMSTR_CHKSM, NULL}; + ULAS_ASMSTR_CHKSM, ULAS_ASMSTR_ADV, NULL}; enum ulas_asmdir dirs[] = { ULAS_ASMDIR_ORG, ULAS_ASMDIR_SET, ULAS_ASMDIR_BYTE, ULAS_ASMDIR_STR, ULAS_ASMDIR_FILL, ULAS_ASMDIR_PAD, - ULAS_ASMDIR_INCBIN, ULAS_ASMDIR_DEF, ULAS_ASMDIR_CHKSM}; + ULAS_ASMDIR_INCBIN, ULAS_ASMDIR_DEF, ULAS_ASMDIR_CHKSM, ULAS_ASMDIR_ADV}; enum ulas_asmdir dir = ULAS_ASMDIR_NONE; @@ -2487,6 +2493,9 @@ int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) { ulas_asmout(dst, &ulas.chksm, 1); other_writes += 1; break; + case ULAS_ASMDIR_ADV: + ulas_asmdiradv(dst, &line, n, &rc); + break; case ULAS_ASMDIR_PAD: // TODO: pad is the same as .fill n, $ - n case ULAS_ASMDIR_NONE: diff --git a/tests/t0.s b/tests/t0.s index 7bd61d4..e9206f1 100644 --- a/tests/t0.s +++ b/tests/t0.s @@ -101,6 +101,6 @@ l2: j1: jp j1 .chksm - ld [hl], a +.adv 1 l3: .db 1 -- 2.30.2