Added enum for instructions

This commit is contained in:
Alex Vanin 2014-01-15 13:54:42 +04:00
parent 9d30a3f8f5
commit 0e0c64007f
2 changed files with 39 additions and 5 deletions

View file

@ -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;
}

13
VaninVM/OpCode.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef OPCODE_H
#define OPCODE_H
enum opcode
{
DLOAD0,
ILOAD0,
DLOAD1,
ILOAD1,
DLOADM1,
ILOADM1,
STOP
};
#endif