diff options
author | Næþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk> | 2016-10-15 12:58:20 +0100 |
---|---|---|
committer | Næþ'n Lasseter <Næþ'n Lasseter nathan@bytemark.co.uk> | 2016-10-15 12:58:20 +0100 |
commit | 22e6cfc502a1ff1d4308d61dbff409a0b7020380 (patch) | |
tree | 87f4112e07356e4ea1164bc0c5b936cb2a71b07e /as.h |
Initial commit
Diffstat (limited to 'as.h')
-rw-r--r-- | as.h | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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); +} |