Last active
March 13, 2018 17:06
-
-
Save kspalaiologos/95fe195653ceff9570470b2cc076fc13 to your computer and use it in GitHub Desktop.
From SUBLEQ compiler for GSQ+ architecture.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
typedef union { | |
char bytes[4]; | |
long instruction; | |
} data_t; | |
int main(int argc, char ** argv) { | |
printf("[SQC] Subleq Compiler for GSQ+ by Krzysztof Szewczyk. All rights reserved.\n"); | |
if(argc==3) { | |
FILE* in = fopen(argv[1],"r"), *out = fopen(argv[2], "wb"); | |
if(in&&out) { | |
data_t compilerData; | |
while(!feof(in)) { | |
fscanf(in,"%d",&compilerData.instruction); | |
fwrite(compilerData.bytes, 1, 4, out); | |
} | |
fclose(in),fclose(out); | |
} else { | |
printf("Could not open one of specified files.\n"); | |
} | |
} else { | |
printf("Invalid parameter amount.\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment