diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-10-29 14:38:33 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2023-10-29 14:38:33 +0200 |
| commit | 5d29afb530ffdaab4b5032b7422da988b31c0867 (patch) | |
| tree | 0135976b951fa4c860a043f07e6d555e40c60d1f /tdump/src/main.c | |
| parent | 80d78c5589d42f81b04e671b28c103a2112458d1 (diff) | |
| download | tri-5d29afb530ffdaab4b5032b7422da988b31c0867.tar.gz tri-5d29afb530ffdaab4b5032b7422da988b31c0867.zip | |
initial working compiled program on simulator
Diffstat (limited to 'tdump/src/main.c')
| -rw-r--r-- | tdump/src/main.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tdump/src/main.c b/tdump/src/main.c new file mode 100644 index 0000000..4008d2c --- /dev/null +++ b/tdump/src/main.c @@ -0,0 +1,51 @@ +#include <tdump/disassembler.h> +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +static const char *cmdline_usage = +"tdump trinary deassembler usage:\n" +" tdump infile\n" +" -h Show usage (this)\n" +" infile File to deassemble\n" +; + +static void usage() +{ + fprintf(stderr, cmdline_usage); +} + +int main(int argc, char *argv[]) +{ + int opt; + while ((opt = getopt(argc, argv, "h")) != -1) { + switch (opt) { + case 'h': + usage(); + exit(EXIT_SUCCESS); + break; + + default: + usage(); + exit(EXIT_FAILURE); + break; + } + } + + if (optind >= argc) { + fprintf(stderr, "no input files\n"); + usage(); + exit(EXIT_FAILURE); + } + + if (optind != argc - 1) { + fprintf(stderr, "too many input files\n"); + usage(); + exit(EXIT_FAILURE); + } + + if (disassemble(argv[optind])) + exit(EXIT_FAILURE); + + return EXIT_SUCCESS; +} |
