summaryrefslogtreecommitdiff
path: root/src/compilo.c
blob: 3f214a6dae1eea6c5b71376e6e7bc643e65ef4f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include "config.h"
#include "exceptions.h"
#include "meta.h"
#include "parser.h"
#include "hash.h"
#include "assembler.h"

typedef void (*sighandler_t)(int);

void invite(void) {
	fprintf(stderr, _("Assembler\n\n"));
}

void init_all(void) {
	fprintf(stderr, _(" o Initialising the meta engine...   "));

	if (meta_init()) {
		exception(1, _("Meta parser init failed."));
	}

	fprintf(stderr, _(" Done!\n o Meta language loading...          "));

	if (meta_load("instructions.txt")) {
		exception(1, _("Meta language loading failed."));
	}
	
	fprintf(stderr, _(" Done!\n o Initialising the assembler core..."));
	
	if (assembler_init()) {
		exception(1, _("Assembler core init failed."));
	}
	
	fprintf(stderr, _(" Done!\n"));
}

void flush_all(void) {
	assembler_flush();
	meta_flush();
}

void segfaulthand(int i) {
	exception(1, _("Signal received: segfault"));
}

int main(void) {
	invite();
	
/*	signal(SIGSEGV, segfaulthand);*/

	fprintf(stderr, _("\nPerforming initialisation...\n\n"));
	init_all();
	
	assemble_file("progtest.asm", "progtest.o");
	
	fprintf(stderr, _("\nPerforming shutdown...\n\n"));
	flush_all();
	
	fprintf(stderr, _("Exitting, bye!\n"));
        return 0;
}