Permalink
Browse files

add prototype of new ops

  • Loading branch information...
1 parent 9e8ddd7 commit b6705e1c1d3b469786b37e029cd1eaacbd7ec18d Jimmy Zhuo committed Apr 3, 2012
Showing with 152 additions and 1 deletion.
  1. +78 −1 src/m0/c/m0_ops.c
  2. +74 −0 src/m0/m0_v2.ops
View
@@ -23,7 +23,7 @@ m0_op_deref( M0_CallFrame *frame, const unsigned char *ops )
unsigned char ref = ops[2];
switch (ref) {
- case CONST:
+ case CONSTS:
{
M0_Constants_Segment *consts =
(M0_Constants_Segment *)frame->registers[ ref ];
@@ -68,27 +68,104 @@ m0_op_add_i( M0_CallFrame *frame, const unsigned char *ops )
}
static void
+m0_op_add_iii( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.i[ops[1]] = frame->regs_ni.i[ops[2]] +
+ frame->regs_ni.i[ops[3]];
+}
+
+static void
+m0_op_add_iIi( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.i[ops[1]] = frame->regs_ni.i[ops[2]] +
+ ops[3];
+}
+
+static void
+m0_op_add_iII( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.i[ops[1]] = ops[2] + ops[3];
+}
+
+static void
m0_op_add_n( M0_CallFrame *frame, const unsigned char *ops )
{
frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] +
frame->regs_ni.n[ops[3]];
}
static void
+m0_op_add_nnn( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] +
+ frame->regs_ni.n[ops[3]];
+}
+
+static void
+m0_op_add_nNn( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] + ops[3];
+}
+
+static void
+m0_op_add_nNN( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.n[ops[1]] = ops[2] + ops[3];
+}
+
+static void
m0_op_sub_i( M0_CallFrame *frame, const unsigned char *ops )
{
frame->regs_ni.i[ops[1]] = frame->regs_ni.i[ops[2]] -
frame->regs_ni.i[ops[3]];
}
static void
+m0_op_sub_iii( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.i[ops[1]] = frame->regs_ni.i[ops[2]] -
+ frame->regs_ni.i[ops[3]];
+}
+
+static void
+m0_op_sub_iIi( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.i[ops[1]] = frame->regs_ni.i[ops[2]] - ops[3];
+}
+
+static void
+m0_op_sub_iII( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.i[ops[1]] = ops[2] - ops[3];
+}
+
+static void
m0_op_sub_n( M0_CallFrame *frame, const unsigned char *ops )
{
frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] -
frame->regs_ni.n[ops[3]];
}
static void
+m0_op_sub_nnn( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] -
+ frame->regs_ni.n[ops[3]];
+}
+
+static void
+m0_op_sub_nNn( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.n[ops[1]] = frame->regs_ni.n[ops[2]] - ops[3];
+}
+
+static void
+m0_op_sub_nNN( M0_CallFrame *frame, const unsigned char *ops )
+{
+ frame->regs_ni.n[ops[1]] = ops[2] - ops[3];
+}
+
+static void
m0_op_convert_n_i( M0_CallFrame *frame, const unsigned char *ops )
{
int64_t *r2 = (int64_t*) &(frame->registers[ops[2]]);
View
@@ -0,0 +1,74 @@
+Here is the new ops definition, <xxxxxx> means it's a retained position, which will be added new op along with requirements change in the future. There will be more ops in the near future.
+
+ 0x00 noop
+ 0x01 goto_IIx
+ 0x02 goto_Iix
+ 0x03 goto_iix
+ 0x04 xxxxxx
+ 0x05 xxxxxx
+ 0x06 goto_if_III
+ 0x07 goto_if_IIi
+ 0x08 xxxxxx
+ 0x09 xxxxxx
+ 0x0A xxxxxx
+ 0x0B goto_chunk_iix
+ 0x0C xxxxxx
+ 0x0D xxxxxx
+ 0x0E xxxxxx
+ 0x0F xxxxxx
+ 0x10 add_iII
+ 0x11 add_iIi
+ 0x12 add_iii
+ 0x13 xxxxxx
+ 0x14 xxxxxx
+ 0x15 add_nNN
+ 0x16 add_nNn
+ 0x17 add_nnn
+ 0x18 xxxxxx
+ 0x19 xxxxxx
+ 0x1A sub_iII
+ 0x1B sub_iIi
+ 0x1C sub_iii
+ 0x1D xxxxxx
+ 0x1E xxxxxx
+ 0x1F sub_nNN
+ 0x20 sub_nNn
+ 0x21 sub_nnn
+ 0x22 xxxxxx
+ 0x23 xxxxxx
+ 0x24 mult_iII
+ 0x25 mult_iIi
+ 0x26 mult_iii
+ 0x27 xxxxxx
+ 0x28 xxxxxx
+ 0x29 mult_nNN
+ 0x2A mult_nNn
+ 0x2B mult_nnn
+ 0x2C xxxxxx
+ 0x2D xxxxxx
+ 0x2E div_iII
+ 0x2F div_iIi
+ 0x30 div_iii
+ 0x31 xxxxxx
+ 0x32 xxxxxx
+ 0x33 div_nNN
+ 0x34 div_nNn
+ 0x35 div_nnn
+ 0x36 xxxxxx
+ 0x37 xxxxxx
+ 0x38 mod_iII
+ 0x39 mod_iIi
+ 0x3A mod_iii
+ 0x3B xxxxxx
+ 0x3C xxxxxx
+ 0x3D mod_nNN
+ 0x3E mod_nNn
+ 0x3F mod_nnn
+ 0x40 xxxxxx
+ 0x41 xxxxxx
+ 0x42 div_nNN
+ 0x43 div_nNn
+ 0x44 div_nnn
+ 0x45 xxxxxx
+ 0x46 xxxxxx
+

0 comments on commit b6705e1

Please sign in to comment.