From 9f7b69e5f7f984534eccdb353b7769f09c455fb8 Mon Sep 17 00:00:00 2001 From: nilsplk Date: Sat, 21 Oct 2023 19:14:48 +0200 Subject: [PATCH] Added the option to test and basic math to execute() --- njvm.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/njvm.c b/njvm.c index da44212..8e2c6b9 100644 --- a/njvm.c +++ b/njvm.c @@ -2,6 +2,10 @@ #include #include +//Comment to disable debug + +#define DEBUG + #define IMMEDIATE(x) ((x) & 0x00FFFFFF) #define HALT 0 @@ -72,14 +76,19 @@ void execute(void) { case PUSHC: break; case ADD: + stackPush(stackPop()+stackPop()); break; case SUB: + stackPush(stackPop()-stackPop()); break; case MUL: + stackPush(stackPop()*stackPop()); break; case DIV: + stackPush(stackPop()/stackPop()); break; case MOD: + stackPush(stackPop()%stackPop()); break; case RDINT: break; @@ -93,8 +102,18 @@ void execute(void) { i++; } } +#ifdef DEBUG + +void tests(){ + printf("test\n"); +} + +#endif /* ifdef DEBUG */ int main(int argc, char *argv[]) { + #ifdef DEBUG + tests(); + #endif /* ifdef DEBUG */ if (argc > 1) useption(argc, argv); else {