From 4fa350a0949fc5797f82f2ee0c23e17e1d0b5fa6 Mon Sep 17 00:00:00 2001 From: Igor Malovitsa Date: Mon, 4 Mar 2024 22:30:03 +0200 Subject: [PATCH] added example && changed flags --- Makefile | 2 +- README.md | 15 +++++++++++++++ hbas.c | 12 ++++++------ 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/Makefile b/Makefile index fab8067..53d8df4 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ hbas: hbas.c ${CC} ${CFLAGS} ${CFLAGS_EXTRA} hbas.c -o hbas example: hbas example.S - ./hbas --bin < example.S > example + ./hbas < example.S > example xxd example clean: diff --git a/README.md b/README.md new file mode 100644 index 0000000..0169751 --- /dev/null +++ b/README.md @@ -0,0 +1,15 @@ +# Holey-bytes VM playground + +This is my take on holey bytes toolchain, currently only an assembler written in C. + +## Building + +Run `make`, or `make CC= CFLAGS_EXTRA=` + +## Usage + +To run the assembler, feed the input file to stdin, and the output will be in stdout. +``` +./hbas --hex < input.S > output.hex +./hbas < input.S > output.bin +``` \ No newline at end of file diff --git a/hbas.c b/hbas.c index 5963838..1c92c1e 100644 --- a/hbas.c +++ b/hbas.c @@ -821,9 +821,9 @@ AsmError assemble(InstHt ht, char *input, size_t len, ByteVec *out, EInfo *einfo } int main(int argc, char **argv) { - int binout = 0; - if (argc >= 2 && strcmp(argv[1], "--bin") == 0) { - binout = 1; + int hex_out = 0; + if (argc >= 2 && strcmp(argv[1], "--hex") == 0) { + hex_out = 1; } int err = 0; @@ -854,10 +854,10 @@ int main(int argc, char **argv) { fprintf(stderr, "\n"); goto done; } - if (binout) { - fwrite(out.buf, 1, out.len, stdout); - } else { + if (hex_out) { hd(out.buf, out.len); + } else { + fwrite(out.buf, 1, out.len, stdout); } done: