#define ULAS_OPTS "hvVp"
// args with value
-#define ULAS_OPTS_ARG "o:"
+#define ULAS_OPTS_ARG "o:l:s:"
#define ULAS_HELP(a, desc) printf("\t-%s\t%s\n", (a), desc);
ULAS_HELP("v", "verbose output");
ULAS_HELP("p", "Stop after preprocessor");
ULAS_HELP("o=path", "Output file");
+ ULAS_HELP("l=path", "Listing file");
+ ULAS_HELP("s=path", "Symbols file");
}
void ulas_version(void) { printf("%s version %s\n", ULAS_NAME, ULAS_VER); }
case 'p':
cfg->preproc_only = 1;
break;
+ case 's':
+ cfg->sym_path = strndup(optarg, ULAS_PATHMAX);
+ break;
+ case 'l':
+ cfg->sym_path = strndup(optarg, ULAS_PATHMAX);
+ break;
case '?':
break;
default:
free(cfg.output_path);
}
+ if (cfg.sym_path) {
+ free(cfg.sym_path);
+ }
+
+ if (cfg.lst_path) {
+ free(cfg.lst_path);
+ }
+
return res;
}
ulas.toks = ulas_tokbuf();
ulas.exprs = ulas_exprbuf();
+ ulas.symout = stdout;
}
void ulas_free(void) {
fclose(ulasout);
}
+ if (cfg.sym_path) {
+ fclose(ulas.symout);
+ ulas.symout = NULL;
+ }
+
+ if (cfg.lst_path) {
+ fclose(ulas.lstout);
+ ulas.lstout = NULL;
+ }
+
if (cfg.argc > 0) {
fclose(ulasin);
}
return ulas_intexpreval(expr, rc);
}
-int ulas_asmimisc(FILE *dst, const char *line, unsigned long n) {}
+int ulas_asmimisc(char *dst, unsigned long max, const char *line,
+ unsigned long n) {
+ return 0;
+}
// assembles an instruction, writes bytes into dst
// returns bytes written or -1 on error
unsigned long n) {
int rc = 0;
+ if ((rc = ulas_asmimisc(dst, max, line, n))) {
+ }
+
return rc;
}
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];
+ char outbuf[ULAS_OUTBUFMAX];
memset(outbuf, 0, ULAS_OUTBUFMAX);
long towrite = 0;
fwrite(outbuf, 1, towrite, dst);
- // TODO: verbose output <address> <bytes>\tline
- fprintf(dst, "%08X\t%s", ulas.address, start);
+ if (ulas.symout) {
+ // TODO: verbose output <address> <bytes>\tline
+ fprintf(ulas.symout, "%08X\t%s", ulas.address, start);
+ }
fail:
return rc;