Fixed comments not working after .db
authorLukas Krickl <lukas@krickl.dev>
Thu, 21 Dec 2023 03:56:24 +0000 (04:56 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 21 Dec 2023 03:56:24 +0000 (04:56 +0100)
src/ulas.c
tests/t0.bin
tests/t0.s

index e7dd2c400a61bd2deda334190ed03011e43999d3..a47d74c08fcf34ec3a449304728f46db944b24ea 100644 (file)
@@ -2280,6 +2280,11 @@ int ulas_asmdirbyte(FILE *dst, const char **line, unsigned long n, int *rc) {
       break;
     }
   } while (*rc != -1 && t.type == ',');
+  
+  // go back one byte if the token was a comment 
+  if (t.type == ULAS_TOK_COMMENT) {
+    *line = *line - strlen(ulas.tok.buf);
+  }
 
   return written;
 }
index bc8c7f24292210a595b2d5a46404dc6d7cb9e57b..8d8083db9bcd0df9cc6868bf2f46e30bcc3ac8d7 100644 (file)
Binary files a/tests/t0.bin and b/tests/t0.bin differ
index 03fd48ed99ce9e01102736de8dbadd82e7270bb8..fcfc3031a9d2cc1447d335fd6e94eedb4f677a93 100644 (file)
@@ -123,3 +123,4 @@ l3: .db 1
 
   jp hl
   ld a, 4/2
+.db 1 ; comment