From 22e6cfc502a1ff1d4308d61dbff409a0b7020380 Mon Sep 17 00:00:00 2001 From: Næþ'n Lasseter Date: Sat, 15 Oct 2016 12:58:20 +0100 Subject: Initial commit --- as.h | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 as.h (limited to 'as.h') diff --git a/as.h b/as.h new file mode 100644 index 0000000..a67e15f --- /dev/null +++ b/as.h @@ -0,0 +1,37 @@ +#define bool char +#define true 1 +#define false 0 + +typedef enum { + NOP, SUBLEQ, SUB, ADD, JMP, MOV, BEQ, NOT, HALT, DATA +} INSTRUCTION; + +typedef struct { + INSTRUCTION i; + int a, b, c; + int args; + bool eof; + bool valid; +} TOKEN; + +void out(FILE* file, int a, int b, int c) { + fwrite(&a, sizeof(int), 1, file); + fwrite(&b, sizeof(int), 1, file); + fwrite(&c, sizeof(int), 1, file); + fflush(file); +} + +#define PLEN 6 +#define Z 3 + +void preamble(FILE* file) { + // Jump over Z + out(file, 1, 1, PLEN); + // Z + out(file, 0, 0, 0); +} + +void postamble(FILE* file) { + // Halt + out(file, -1, -1, -1); +} -- cgit v1.2.3