diff --git a/Makefile b/Makefile index 96df21d..f56f609 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,9 @@ CC = gcc F = prog.bin # Compiler flags -CFLAGS = -I ./bigint/build/include -L ./bigint/build/lib -g -Wall -std=c99 -pedantic +CFLAGS = -g -Wall -Ibigint/build/include + +LDFLAGS = -g -Wall -Lbigint/build/lib # Source file SRC = njvm.c @@ -15,9 +17,15 @@ SRC = njvm.c # Executable name TARGET = njvm +njvm.o: + $(CC) $(CFLAGS) -o njvm.o -c njvm.c + +support.o: + $(CC) $(CFLAGS) -o support.o -c support.c + # Default target -all: - $(CC) $(CFLAGS) -o $(TARGET) $(SRC) +all: njvm.o support.o + $(CC) $(LDFLAGS) -o $(TARGET) njvm.o support.o -lbigint # Clean up clean: rm -f $(OBJ) $(TARGET) diff --git a/a.out b/a.out new file mode 100755 index 0000000..3f28add Binary files /dev/null and b/a.out differ diff --git a/compile_flags.txt b/compile_flags.txt new file mode 100644 index 0000000..63956da --- /dev/null +++ b/compile_flags.txt @@ -0,0 +1,3 @@ +-Ibigint/build/include +-Lbigint/build/lib +-lbigint diff --git a/njvm.c b/njvm.c index ff6b17e..226326b 100644 --- a/njvm.c +++ b/njvm.c @@ -8,7 +8,7 @@ #include "codeReader.c" #include "SDA.c" #include "debugMenu.c" - +#include "bigint.h" // Debug int debug = 0; @@ -28,6 +28,13 @@ unsigned fp; void version(void) { printf("Ninja Virtual Machine version %i (compiled %s, %s)\n", 0, __DATE__, __TIME__); + bigFromInt(9); + bip.op1 = bip.res; + bigFromInt(10); + bip.op2 = bip.res; + bigAdd(); + bip.op1 = bip.res; + bigPrint(stdout); } void help(void) { diff --git a/njvm.o b/njvm.o new file mode 100644 index 0000000..0390d91 Binary files /dev/null and b/njvm.o differ diff --git a/objref.c b/objref.c new file mode 100644 index 0000000..9b22149 --- /dev/null +++ b/objref.c @@ -0,0 +1,10 @@ +#ifndef OBJREF +#define OBJREF + +typedef struct { + unsigned int size; + unsigned char data[1]; +} *ObjRef; + +#endif /* ifndef OBJREF +#define OBJREF */ diff --git a/support.c b/support.c new file mode 100644 index 0000000..cc7f6b6 --- /dev/null +++ b/support.c @@ -0,0 +1,27 @@ +#include "support.h" +#include +#include + +#include "objref.c" + +void fatalError(char *msg){ + printf("Fatal error: %s\n", msg); + exit(1); +} + +void * newPrimObject(int dataSize) { + ObjRef bigObjRef; + + bigObjRef = malloc(sizeof(unsigned int) + + dataSize * sizeof(unsigned char)); + if (bigObjRef == NULL) { + fatalError("newPrimObject() got no memory"); + } + bigObjRef->size = dataSize; + return bigObjRef; +} + +void * getPrimObjectDataPointer(void * obj){ + ObjRef oo = ((ObjRef) (obj)); + return oo->data; +} diff --git a/support.o b/support.o new file mode 100644 index 0000000..b9bac9c Binary files /dev/null and b/support.o differ diff --git a/test.c b/test.c new file mode 100644 index 0000000..986bde7 --- /dev/null +++ b/test.c @@ -0,0 +1,9 @@ +#include +#include "bigint.h" + +int main(int argc, char *argv[]) +{ + printf("Hallo Welt\n"); + bigFromInt(5); + return 0; +}