fprintf((f), "%s", (fmt)); \
}
+// this is a bit of a hack to get the int expression to evaluate anyway
+// because expressions only work in the final pass
+// Beware that this can cause unforseen writes to the file and should really
+// only be uesd to evalulate an expression that needs to be evaled during
+// all passes and nothing else!
+#define ULAS_EVALEXPRS(...) \
+ { \
+ int pass = ulas.pass; \
+ ulas.pass = ULAS_PASS_FINAL; \
+ __VA_ARGS__; \
+ ulas.pass = pass; \
+ }
+
/**
* Output target files
*/
if (rc != -1) {
rc = found_dir;
}
-
+
free(ulas.filename);
ulas.filename = prev_path;
ulas.line = prev_lines;
-
+
fclose(f);
fclose(tmp);
return rc;
ULASERR("Expected ,\n");
return 0;
}
+ int count = 0;
- int count = ulas_intexpr(line, n, rc);
+ ULAS_EVALEXPRS(count = ulas_intexpr(line, n, rc));
if (count < 0) {
ULASERR("Count must be positive\n");
return 0;
}
switch (dir) {
- case ULAS_ASMDIR_ORG:
- ulas.address = ulas_intexpr(&line, strnlen(start, n), &rc);
+ case ULAS_ASMDIR_ORG: {
+ ULAS_EVALEXPRS(ulas.address =
+ ulas_intexpr(&line, strnlen(start, n), &rc));
break;
+ }
case ULAS_ASMDIR_DEF:
// only do this in the final pass
rc = ulas_asmdirdef(&line, n);