Updated testing for vvm
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
override CFLAGS+=-Werror -Wall -g -fPIC -O2 -DNDEBUG -std=c99 -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wconversion -Wuninitialized
|
override CFLAGS+=-Werror -Wall -g -fPIC -O2 -DNDEBUG -std=c99 -ftrapv -Wfloat-equal -Wundef -Wwrite-strings -Wconversion -Wuninitialized
|
||||||
|
DEBUG+=-DEBUG=1
|
||||||
PREFIX=/usr/bin
|
PREFIX=/usr/bin
|
||||||
BUILDDIR=bin/
|
BUILDDIR=bin/
|
||||||
|
|
||||||
@@ -14,6 +15,10 @@ all:
|
|||||||
dev:
|
dev:
|
||||||
make all CFLAGS+=-Wshadow -Wunreachable-code -Wswitch-enum -Wswitch-default -Wcast-align -Winit-self -Wpointer-arith -Weffc++
|
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!)
|
#Cleans directory(no uninstall!)
|
||||||
clean:
|
clean:
|
||||||
rm -rf bin
|
rm -rf bin
|
||||||
|
@@ -1,26 +1,5 @@
|
|||||||
#include "vm.h"
|
#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
|
* @brief main
|
||||||
* argc -> the argument counter
|
* argc -> the argument counter
|
||||||
@@ -29,17 +8,9 @@ int factorial[] = {
|
|||||||
* executes code in my dsl.
|
* executes code in my dsl.
|
||||||
*/
|
*/
|
||||||
int main(int argc, char** argv){
|
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)
|
if(argc != 2)
|
||||||
die(127, "Please specify exactly one file to execute.");
|
die(127, "Please specify exactly one file to execute.");
|
||||||
program prog = vm_parse(argv[1]);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user