added example && changed flags
This commit is contained in:
parent
376117ace5
commit
4fa350a094
2
Makefile
2
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:
|
||||
|
|
15
README.md
Normal file
15
README.md
Normal file
|
@ -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=<your preferred C compiler> CFLAGS_EXTRA=<more flags>`
|
||||
|
||||
## 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
|
||||
```
|
12
hbas.c
12
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:
|
||||
|
|
Loading…
Reference in a new issue