summaryrefslogtreecommitdiff
path: root/skullfuck.c
diff options
context:
space:
mode:
Diffstat (limited to 'skullfuck.c')
-rw-r--r--skullfuck.c31
1 files changed, 12 insertions, 19 deletions
diff --git a/skullfuck.c b/skullfuck.c
index 0f58198..7d9e0a8 100644
--- a/skullfuck.c
+++ b/skullfuck.c
@@ -25,7 +25,9 @@
#include <getopt.h>
-#ifdef x86_64
+#if defined(x86_64)
+#define ARCH "x86_64"
+#define OS "Linux"
#define INC_DATA_PTR "\tincq %rsi\n"
#define DEC_DATA_PTR "\tdecq %rsi\n"
#define INC_DATA "\tincb (%rsi)\n"
@@ -52,10 +54,9 @@
#define EXIT "\tmovq $0x3c, %rax\n" \
"\tmovq $0x00, %rdi\n" \
"\tsyscall\n"
-#endif
-
-
-#ifdef i686
+#elif defined(i686)
+#define ARCH "i686"
+#define OS "Linux"
#define INC_DATA_PTR "\tincl %ecx\n"
#define DEC_DATA_PTR "\tdecl %ecx\n"
#define INC_DATA "\tincb (%ecx)\n"
@@ -84,14 +85,6 @@
"\tint $0x80\n"
#endif
-#ifndef AS
-#define AS /bin/as
-#endif
-
-#ifndef LD
-#define LD /bin/ld
-#endif
-
#define MAX_CELLS 30000
#define MAX_LOOP_DEPTH 64
@@ -135,8 +128,8 @@ static void write_instructions(FILE *out, char *in) {
int next_loop = 0, cur_loop = 0;
struct loop_stack *loops = calloc(sizeof(struct loop_stack), 1);
- for (int i = 0; in[i] != '\0'; i++) {
- switch (in[i]) {
+ for (char *cur = in; *cur != '\0'; cur++) {
+ switch(*cur) {
case '>':
fputs(INC_DATA_PTR, out);
break;
@@ -263,8 +256,9 @@ static struct params parse_args(int argc, char **argv) {
"\t-o file\t\tPlace the output in file.\n");
exit(EXIT_SUCCESS);
case 'v':
- printf("Skullfuck compiler for Brainfuck, version %s.\nMade "
- "by Jakob. <http://jakob.space>\n", SKULLFUCK_VERSION);
+ printf("Skullfuck compiler for Brainfuck, version %s.\n"
+ "Toolchain for %s %s.\nDeveloped by Jakob. "
+ "<http://jakob.space>\n", SKULLFUCK_VERSION, ARCH, OS);
exit(EXIT_SUCCESS);
case 'S':
p.compile_only = true;
@@ -282,8 +276,7 @@ static struct params parse_args(int argc, char **argv) {
}
p.in = argv[count];
-
- p.as = "/tmp/skullfuck_tmp.s";
+ p.as = "/tmp/skullfuck_tmp.s";
if (p.compile_only) {
p.out = p.out == NULL ? "./out.s" : p.out;
p.as = p.out;