Skip to content

Instantly share code, notes, and snippets.

@kspalaiologos
Last active March 13, 2018 17:06
Show Gist options
  • Save kspalaiologos/95fe195653ceff9570470b2cc076fc13 to your computer and use it in GitHub Desktop.
Save kspalaiologos/95fe195653ceff9570470b2cc076fc13 to your computer and use it in GitHub Desktop.
From SUBLEQ compiler for GSQ+ architecture.
#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