Added .adv directive
authorLukas Krickl <lukas@krickl.dev>
Mon, 11 Dec 2023 20:20:11 +0000 (21:20 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 11 Dec 2023 20:20:11 +0000 (21:20 +0100)
include/ulas.h
src/ulas.c
tests/t0.s

index e220cf6bcdc66314e958d25930fb94ad395a0b62..4c65f0369c90ad01377047408310e384251aede4 100644 (file)
@@ -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 <int>
+  // advance .org by n bytes without writing to rom
+  ULAS_ASMDIR_ADV,
 };
 
 // amount of registers
index 666de32518f2afc857bd55366a3e4ca408ba9b67..0117150fd186cfca2b8f28eea28f617ea4714c51 100644 (file)
@@ -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:
index 7bd61d4771f622f70736d2cfe2aef038788354ae..e9206f1f6b013e36a91a8e6702894ad6476d505e 100644 (file)
@@ -101,6 +101,6 @@ l2:
 j1:
   jp j1
 .chksm
-
   ld [hl], a
+.adv 1
 l3: .db 1