2 + Z: no operand (Z,Z,Z,Z)
4 + BB: 8+8bit (BB,SB,BS,SS)
5 + BBB: 8+8+8bit (BBB,SBB,BSB,SSB)
6 + BS: 8+16bit (BS,SS,BS,BS)
11 /*-----------------------------------------------------------------------
12 operation code operands semantics
13 ------------------------------------------------------------------------*/
14 OPCODE(NOP, Z) /* no operation */
15 OPCODE(MOVE, BB) /* R(a) = R(b) */
16 OPCODE(LOADL, BB) /* R(a) = Pool(b) */
17 OPCODE(LOADI, BB) /* R(a) = mrb_int(b) */
18 OPCODE(LOADINEG, BB) /* R(a) = mrb_int(-b) */
19 OPCODE(LOADI__1, B) /* R(a) = mrb_int(-1) */
20 OPCODE(LOADI_0, B) /* R(a) = mrb_int(0) */
21 OPCODE(LOADI_1, B) /* R(a) = mrb_int(1) */
22 OPCODE(LOADI_2, B) /* R(a) = mrb_int(2) */
23 OPCODE(LOADI_3, B) /* R(a) = mrb_int(3) */
24 OPCODE(LOADI_4, B) /* R(a) = mrb_int(4) */
25 OPCODE(LOADI_5, B) /* R(a) = mrb_int(5) */
26 OPCODE(LOADI_6, B) /* R(a) = mrb_int(6) */
27 OPCODE(LOADI_7, B) /* R(a) = mrb_int(7) */
28 OPCODE(LOADSYM, BB) /* R(a) = Syms(b) */
29 OPCODE(LOADNIL, B) /* R(a) = nil */
30 OPCODE(LOADSELF, B) /* R(a) = self */
31 OPCODE(LOADT, B) /* R(a) = true */
32 OPCODE(LOADF, B) /* R(a) = false */
33 OPCODE(GETGV, BB) /* R(a) = getglobal(Syms(b)) */
34 OPCODE(SETGV, BB) /* setglobal(Syms(b), R(a)) */
35 OPCODE(GETSV, BB) /* R(a) = Special[Syms(b)] */
36 OPCODE(SETSV, BB) /* Special[Syms(b)] = R(a) */
37 OPCODE(GETIV, BB) /* R(a) = ivget(Syms(b)) */
38 OPCODE(SETIV, BB) /* ivset(Syms(b),R(a)) */
39 OPCODE(GETCV, BB) /* R(a) = cvget(Syms(b)) */
40 OPCODE(SETCV, BB) /* cvset(Syms(b),R(a)) */
41 OPCODE(GETCONST, BB) /* R(a) = constget(Syms(b)) */
42 OPCODE(SETCONST, BB) /* constset(Syms(b),R(a)) */
43 OPCODE(GETMCNST, BB) /* R(a) = R(a)::Syms(b) */
44 OPCODE(SETMCNST, BB) /* R(a+1)::Syms(b) = R(a) */
45 OPCODE(GETUPVAR, BBB) /* R(a) = uvget(b,c) */
46 OPCODE(SETUPVAR, BBB) /* uvset(b,c,R(a)) */
47 OPCODE(JMP, S) /* pc=a */
48 OPCODE(JMPIF, BS) /* if R(b) pc=a */
49 OPCODE(JMPNOT, BS) /* if !R(b) pc=a */
50 OPCODE(JMPNIL, BS) /* if R(b)==nil pc=a */
51 OPCODE(ONERR, S) /* rescue_push(a) */
52 OPCODE(EXCEPT, B) /* R(a) = exc */
53 OPCODE(RESCUE, BB) /* R(b) = R(a).isa?(R(b)) */
54 OPCODE(POPERR, B) /* a.times{rescue_pop()} */
55 OPCODE(RAISE, B) /* raise(R(a)) */
56 OPCODE(EPUSH, B) /* ensure_push(SEQ[a]) */
57 OPCODE(EPOP, B) /* A.times{ensure_pop().call} */
58 OPCODE(SENDV, BB) /* R(a) = call(R(a),Syms(b),*R(a+1)) */
59 OPCODE(SENDVB, BB) /* R(a) = call(R(a),Syms(b),*R(a+1),&R(a+2)) */
60 OPCODE(SEND, BBB) /* R(a) = call(R(a),Syms(b),R(a+1),...,R(a+c)) */
61 OPCODE(SENDB, BBB) /* R(a) = call(R(a),Syms(Bx),R(a+1),...,R(a+c),&R(a+c+1)) */
62 OPCODE(CALL, Z) /* R(0) = self.call(frame.argc, frame.argv) */
63 OPCODE(SUPER, BB) /* R(a) = super(R(a+1),... ,R(a+b+1)) */
64 OPCODE(ARGARY, BS) /* R(a) = argument array (16=m5:r1:m5:d1:lv4) */
65 OPCODE(ENTER, W) /* arg setup according to flags (23=m5:o5:r1:m5:k5:d1:b1) */
66 OPCODE(KEY_P, BB) /* R(a) = kdict.key?(Syms(b)) # todo */
67 OPCODE(KEYEND, Z) /* raise unless kdict.empty? # todo */
68 OPCODE(KARG, BB) /* R(a) = kdict[Syms(b)]; kdict.delete(Syms(b)) # todo */
69 OPCODE(RETURN, B) /* return R(a) (normal) */
70 OPCODE(RETURN_BLK, B) /* return R(a) (in-block return) */
71 OPCODE(BREAK, B) /* break R(a) */
72 OPCODE(BLKPUSH, BS) /* R(a) = block (16=m5:r1:m5:d1:lv4) */
73 OPCODE(ADD, B) /* R(a) = R(a)+R(a+1) */
74 OPCODE(ADDI, BB) /* R(a) = R(a)+mrb_int(c) */
75 OPCODE(SUB, B) /* R(a) = R(a)-R(a+1) */
76 OPCODE(SUBI, BB) /* R(a) = R(a)-C */
77 OPCODE(MUL, B) /* R(a) = R(a)*R(a+1) */
78 OPCODE(DIV, B) /* R(a) = R(a)/R(a+1) */
79 OPCODE(EQ, B) /* R(a) = R(a)==R(a+1) */
80 OPCODE(LT, B) /* R(a) = R(a)<R(a+1) */
81 OPCODE(LE, B) /* R(a) = R(a)<=R(a+1) */
82 OPCODE(GT, B) /* R(a) = R(a)>R(a+1) */
83 OPCODE(GE, B) /* R(a) = R(a)>=R(a+1) */
84 OPCODE(ARRAY, BB) /* R(a) = ary_new(R(a),R(a+1)..R(a+b)) */
85 OPCODE(ARRAY2, BBB) /* R(a) = ary_new(R(b),R(b+1)..R(b+c)) */
86 OPCODE(ARYCAT, B) /* ary_cat(R(a),R(a+1)) */
87 OPCODE(ARYPUSH, B) /* ary_push(R(a),R(a+1)) */
88 OPCODE(ARYDUP, B) /* R(a) = ary_dup(R(a)) */
89 OPCODE(AREF, BBB) /* R(a) = R(b)[c] */
90 OPCODE(ASET, BBB) /* R(a)[c] = R(b) */
91 OPCODE(APOST, BBB) /* *R(a),R(a+1)..R(a+c) = R(a)[b..] */
92 OPCODE(INTERN, B) /* R(a) = intern(R(a)) */
93 OPCODE(STRING, BB) /* R(a) = str_dup(Lit(b)) */
94 OPCODE(STRCAT, B) /* str_cat(R(a),R(a+1)) */
95 OPCODE(HASH, BB) /* R(a) = hash_new(R(a),R(a+1)..R(a+b)) */
96 OPCODE(HASHADD, BB) /* R(a) = hash_push(R(a),R(a+1)..R(a+b)) */
97 OPCODE(HASHCAT, B) /* R(a) = hash_cat(R(a),R(a+1)) */
98 OPCODE(LAMBDA, BB) /* R(a) = lambda(SEQ[b],L_LAMBDA) */
99 OPCODE(BLOCK, BB) /* R(a) = lambda(SEQ[b],L_BLOCK) */
100 OPCODE(METHOD, BB) /* R(a) = lambda(SEQ[b],L_METHOD) */
101 OPCODE(RANGE_INC, B) /* R(a) = range_new(R(a),R(a+1),FALSE) */
102 OPCODE(RANGE_EXC, B) /* R(a) = range_new(R(a),R(a+1),TRUE) */
103 OPCODE(OCLASS, B) /* R(a) = ::Object */
104 OPCODE(CLASS, BB) /* R(a) = newclass(R(a),Syms(b),R(a+1)) */
105 OPCODE(MODULE, BB) /* R(a) = newmodule(R(a),Syms(b)) */
106 OPCODE(EXEC, BB) /* R(a) = blockexec(R(a),SEQ[b]) */
107 OPCODE(DEF, BB) /* R(a).newmethod(Syms(b),R(a+1)) */
108 OPCODE(ALIAS, BB) /* alias_method(target_class,Syms(a),Syms(b)) */
109 OPCODE(UNDEF, B) /* undef_method(target_class,Syms(a)) */
110 OPCODE(SCLASS, B) /* R(a) = R(a).singleton_class */
111 OPCODE(TCLASS, B) /* R(a) = target_class */
112 OPCODE(DEBUG, BBB) /* print a,b,c */
113 OPCODE(ERR, B) /* raise(LocalJumpError, Lit(a)) */
114 OPCODE(EXT1, Z) /* make 1st operand 16bit */
115 OPCODE(EXT2, Z) /* make 2nd operand 16bit */
116 OPCODE(EXT3, Z) /* make 1st and 2nd operands 16bit */
117 OPCODE(STOP, Z) /* stop VM */