BIN_INSTALL_DIR=/usr/local/bin
MAN_INSTALL_DIR=/usr/local/man
-_OBJ = $(MAIN) ulas.o archs.o
+_OBJ = $(MAIN) ulas.o archs.o uldas.o
OBJ = $(patsubst %,$(ODIR)/%,$(_OBJ))
all: bin test
#define ULAS_VER "0.0.1"
// args without value
-#define ULAS_OPTS "hvVp"
+#define ULAS_OPTS "hvVpd"
// args with value
#define ULAS_OPTS_ARG "o:l:s:i:w:"
ULAS_HELP("l=path", "Listing file");
ULAS_HELP("s=path", "Symbols file");
ULAS_HELP("i=path", "Add include search path");
+ ULAS_HELP("d", "Disassemble a file");
ULAS_HELP("w=warning", "Toggle warnings: a=all, o=overflow");
}
case 'w':
cfg->warn_level ^= warnings[(int)optarg[0]];
break;
+ case 'd':
+ cfg->disas = 1;
+ break;
case '?':
break;
default:
#include <string.h>
#include <assert.h>
#include <sys/time.h>
+#include "uldas.h"
FILE *ulasin = NULL;
FILE *ulasout = NULL;
ULASDBG("input: %s\n", cfg.argv[0]);
ulasin = ulas_fopen(cfg.argv[0], "re", stdin);
}
-
- // only do 2 pass if we have a file as input
- // because we cannot really rewind stdout
- if (!cfg.preproc_only && ulasin != stdin) {
- ulas.pass = ULAS_PASS_RESOLVE;
- }
-
FILE *preprocdst = NULL;
- while (ulas.pass >= 0) {
- if (ulascfg.verbose) {
- fprintf(ulaserr, "[Pass %d]\n", ulas.pass);
+
+ if (!ulascfg.disas) {
+ // only do 2 pass if we have a file as input
+ // because we cannot really rewind stdout
+ if (!cfg.preproc_only && ulasin != stdin) {
+ ulas.pass = ULAS_PASS_RESOLVE;
}
- ulas_nextpass();
+ while (ulas.pass >= 0) {
+ if (ulascfg.verbose) {
+ fprintf(ulaserr, "[Pass %d]\n", ulas.pass);
+ }
- // FIXME: it would be nice if we could do the 2 pass by clearing the
- // tmpfile instead of making an entierly new one
- if (cfg.preproc_only) {
- preprocdst = ulasout;
- } else {
- preprocdst = tmpfile();
- }
+ ulas_nextpass();
- if (ulas_preproc(preprocdst, ulasin) == -1) {
- rc = -1;
- goto cleanup;
- }
+ // FIXME: it would be nice if we could do the 2 pass by clearing the
+ // tmpfile instead of making an entierly new one
+ if (cfg.preproc_only) {
+ preprocdst = ulasout;
+ } else {
+ preprocdst = tmpfile();
+ }
- if (ulas.pass > ULAS_PASS_FINAL) {
- fclose(preprocdst);
- preprocdst = NULL;
- rewind(ulasin);
+ if (ulas_preproc(preprocdst, ulasin) == -1) {
+ rc = -1;
+ goto cleanup;
+ }
+
+ if (ulas.pass > ULAS_PASS_FINAL) {
+ fclose(preprocdst);
+ preprocdst = NULL;
+ rewind(ulasin);
+ }
+ ulas.pass -= 1;
}
- ulas.pass -= 1;
+ } else {
+ rc = ulas_dasm(ulasin, ulasout);
}
cleanup: