From 0e0c64007f3d8ed5e1721de0af4e383c8430eae2 Mon Sep 17 00:00:00 2001 From: AlexVanin Date: Wed, 15 Jan 2014 13:54:42 +0400 Subject: [PATCH] Added enum for instructions --- VaninVM/Main.c | 31 ++++++++++++++++++++++++++----- VaninVM/OpCode.h | 13 +++++++++++++ 2 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 VaninVM/OpCode.h diff --git a/VaninVM/Main.c b/VaninVM/Main.c index daa0427..85ed4f4 100644 --- a/VaninVM/Main.c +++ b/VaninVM/Main.c @@ -1,5 +1,6 @@ #include "IOcode.h" #include "TOS.h" +#include "OpCode.h" int main(int argc, char** argv) @@ -19,12 +20,32 @@ int main(int argc, char** argv) { switch (code[ip]) { - case 1: - push_double(12.1); - ip++; - break; + case DLOAD0: + // DO(DLOAD0, "Load double 0 on TOS.", 1) + push_double(0); + ip++; break; + case ILOAD0: + //DO(ILOAD0, "Load int 0 on TOS.", 1) + push_int(0); + ip++; break; + case DLOAD1: + //DO(DLOAD1, "Load double 1 on TOS.", 1) + push_double(1); + ip++; break; + case ILOAD1: + //DO(ILOAD1, "Load int 1 on TOS.", 1) + push_int(1); + ip++; break; + case DLOADM1: + //DO(DLOADM1, "Load double -1 on TOS.", 1) + push_double(-1); + ip++; break; + case ILOADM1: + //DO(ILOADM1, "Load int -1 on TOS.", 1) + push_int(-1); + ip++; break; - case 78: + case STOP: exec_status = 0; break; } diff --git a/VaninVM/OpCode.h b/VaninVM/OpCode.h new file mode 100644 index 0000000..ae42a0f --- /dev/null +++ b/VaninVM/OpCode.h @@ -0,0 +1,13 @@ +#ifndef OPCODE_H +#define OPCODE_H +enum opcode +{ + DLOAD0, + ILOAD0, + DLOAD1, + ILOAD1, + DLOADM1, + ILOADM1, + STOP +}; +#endif \ No newline at end of file