Add disassembler alternative format

This commit is contained in:
hiperiondev
2023-08-22 18:23:27 -03:00
parent 5721edc2d1
commit 6b8e95d250
8 changed files with 1110 additions and 244 deletions

View File

@@ -1,8 +1,46 @@
#include <stdlib.h>
#include "cargs.h"
#include "disassembler.h"
int main(int argc, const char* argv[]) {
disassemble(argv[1]);
static struct cag_option options[] = {
{
.identifier = 'a',
.access_letters = "a",
.access_name = NULL,
.value_name = NULL,
.description = "Alternate format"
}, {
.identifier = 'h',
.access_letters = "h",
.access_name = "help",
.description = "Shows the command help"
}
};
struct options {
bool alternate_flag;
};
int main(int argc, char *argv[]) {
char identifier;
cag_option_context context;
struct options config = { false };
cag_option_prepare(&context, options, CAG_ARRAY_SIZE(options), argc, argv);
while (cag_option_fetch(&context)) {
identifier = cag_option_get(&context);
switch (identifier) {
case 'a':
config.alternate_flag = true;
break;
case 'h':
printf("Usage: disassembler [OPTION] file\n");
cag_option_print(options, CAG_ARRAY_SIZE(options), stdout);
return EXIT_SUCCESS;
}
}
disassemble(argv[context.index], config.alternate_flag);
return EXIT_SUCCESS;
}