Updated testing for vvm

This commit is contained in:
Veit Heller
2014-10-08 12:13:33 +02:00
parent efbbb37d36
commit eecd59687b
2 changed files with 6 additions and 30 deletions

View File

@@ -1,4 +1,5 @@
override CFLAGS+=-Werror -Wall -g -fPIC -O2 -DNDEBUG -std=c99 -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wconversion -Wuninitialized
DEBUG+=-DEBUG=1
PREFIX=/usr/bin
BUILDDIR=bin/
@@ -14,6 +15,10 @@ all:
dev:
make all CFLAGS+=-Wshadow -Wunreachable-code -Wswitch-enum -Wswitch-default -Wcast-align -Winit-self -Wpointer-arith -Weffc++
debug:
mkdir $(BUILDDIR) 2> /dev/null || true
cc $(CFLAGS) $(DEBUG) $(SOURCES) -o $(BUILDDIR)$(TARGET)
#Cleans directory(no uninstall!)
clean:
rm -rf bin

View File

@@ -1,26 +1,5 @@
#include "vm.h"
/*A factorial program in my dsl*/
int factorial[] = {
LOAD, -3,
ICONST, 2,
ILT,
BRF, 10,
ICONST, 1,
RET,
LOAD, -3,
LOAD, -3,
ICONST, 1,
ISUB,
CALL, 0, 1,
IMULT,
RET,
ICONST, 12,
CALL, 0, 1,
IPRINT,
HALT
};
/**
* @brief main
* argc -> the argument counter
@@ -29,17 +8,9 @@ int factorial[] = {
* executes code in my dsl.
*/
int main(int argc, char** argv){
/*int code[] = { ICONST, 72, PRINT, ICONST, 101, PRINT, ICONST, 108,
PRINT, ICONST, 108, PRINT, ICONST, 111, PRINT, ICONST, 44, PRINT,
ICONST, 32, PRINT, ICONST, 119, PRINT, ICONST, 111, PRINT,
ICONST, 114, PRINT, ICONST, 108, PRINT, ICONST, 100, PRINT,
ICONST, 33, GSTORE, 0, GLOAD, 0, PRINT, ICONST, 10, PRINT, HALT };
vm_execute(factorial, 22, 0, sizeof(factorial) / sizeof(factorial[0]));
printf("\n");
vm_execute(code, 0, 1, sizeof(code) / sizeof(code[0]));*/
if(argc != 2)
die(127, "Please specify exactly one file to execute.");
program prog = vm_parse(argv[1]);
vm_execute(prog.code, 22, 0, prog.length);
vm_execute(prog.code, prog.entrypoint, 0, prog.length);
return 0;
}