diff options
author | Benedikt Böhm <bb@xnull.de> | 2009-05-18 20:53:42 +0200 |
---|---|---|
committer | Benedikt Böhm <bb@xnull.de> | 2009-05-18 20:53:42 +0200 |
commit | 49f510d2d60129526832bfcd9c0f4049962bc80e (patch) | |
tree | 2828b773c75bdbc4014a3421c8046778a1a2b11b /src/emu/riscas.c | |
parent | 144258f0196b69cbdd2f29bd501276942efc3182 (diff) | |
download | swppy-49f510d2d60129526832bfcd9c0f4049962bc80e.tar.gz swppy-49f510d2d60129526832bfcd9c0f4049962bc80e.tar.xz swppy-49f510d2d60129526832bfcd9c0f4049962bc80e.zip |
move stuff around and create initial source structure
Diffstat (limited to 'src/emu/riscas.c')
-rw-r--r-- | src/emu/riscas.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/emu/riscas.c b/src/emu/riscas.c new file mode 100644 index 0000000..e4180b2 --- /dev/null +++ b/src/emu/riscas.c @@ -0,0 +1,40 @@ +#include <stdlib.h> +#include <stdint.h> +#include <stdio.h> + +#include "asm.h" +#include "log.h" + +static +void usage(int rc) +{ + fprintf(stderr, "Usage: riscas <source> <program>\n"); + exit(rc); +} + +int main(int argc, char *argv[]) +{ + if (argc < 3) { + usage(EXIT_FAILURE); + } + + FILE *sfd; + if ((sfd = fopen(argv[1], "r")) == NULL) + pdie("could not open source %s", argv[1]); + + FILE *pfd; + if ((pfd = fopen(argv[2], "w")) == NULL) + pdie("could not open program %s", argv[2]); + + char line[128]; + while (fgets(line, 128, sfd)) { + uint32_t IR = compile(line); + + if (IR == 0xFFFFFFFF) + die("illegal instruction: %s", line); + + fwrite(&IR, sizeof(uint32_t), 1, pfd); + } + + return 0; +} |