-
Notifications
You must be signed in to change notification settings - Fork 0
/
opcode_data.txt
166 lines (142 loc) · 4.74 KB
/
opcode_data.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
// Defines the opcodes for the Cajeput VM
// Currently, the compiler gets its knowledge of what binary operators exist
// from here (though not unary operators or casts - FIXME!)
0 NOOP: ->
1 ABORT: -> (INVALID) // should never appear in actual bytecode!
2 ADD_II: int + int -> int
3 SUB_II: int - int -> int
4 MUL_II: int * int -> int
5 DIV_II: int / int -> int
6 ADD_FF: float + float -> float
7 SUB_FF: float - float -> float
8 MUL_FF: float * float -> float
9 DIV_FF: float / float -> float
10 RET: -> (RET)
11 MOD_II: int % int -> int
12 AND_II: int & int -> int
13 OR_II: int | int -> int
14 XOR_II: int ^ int -> int
15 NOT_I: ~ int -> int
16 SHL: int << int -> int
17 SHR: int >> int -> int
18 AND_L: int && int -> int // non-short circuiting, of course
19 OR_L: int || int -> int
20 NOT_L: ! int -> int
21 COND: int -> (COND) // pops value from stack, skips next insn if it's 0
22 NCOND: int -> (COND) // pops value from stack, skips next insn unless it's 0
23 EQ_II: int == int -> int
24 NEQ_II: int != int -> int
25 GR_II: int > int -> int
26 LES_II: int < int -> int
27 GEQ_II: int >= int -> int
28 LEQ_II: int <= int -> int
29 DROP_I: int ->
30 DROP_P: ptr ->
31 DROP_I3: vect ->
32 DROP_I4: rot ->
33 PRINT_I: int ->
34 PRINT_F: float ->
35 PRINT_STR: str ->
36 CAST_I2F: int -> float
37 CAST_F2I: float -> int
38 CAST_I2S: int -> str
39 CAST_F2S: float -> str
40 BEGIN_CALL: -> ret_addr // magic. Move somewhere saner?
41 INC_I: int++ -> int // for optimisation of i++
42 DEC_I: int-- -> int
43 ADD_SS: str + str -> str
// 44 ADD_SI: str + int -> str
// 45 ADD_SF: str + float -> str
// 46 ADD_SV: str + vect -> str // needed?
// 47 ADD_SR: str + rot -> str // needed
48 EQ_FF: float == float -> int // need to implement these
49 NEQ_FF: float != float -> int
50 GR_FF: float > float -> int
51 LES_FF: float < float -> int
52 GEQ_FF: float >= float -> int
53 LEQ_FF: float <= float -> int
54 EQ_SS: str == str -> int
// now for some casts in boolean contexts
55 CAST_F2B: float -> int // not same as F2I
56 CAST_S2B: str -> int
57 CAST_K2B: key -> int // again, not same as S2B.
58 CAST_L2B: list -> int
59 CAST_V2B: vect -> int
60 CAST_R2B: rot -> int
// most of these function replacements aren't even implemented yet!
61 ABS: int -> int func:llAbs
62 FABS: float -> float func:llFabs
63 SQRT: float -> float func:llSqrt
64 POW: float float -> float func:llPow
65 SIN: float -> float func:llSin
66 COS: float -> float func:llCos
67 TAN: float -> float func:llTan
68 ASIN: float -> float func:llAsin
69 ACOS: float -> float func:llAcos
70 ATAN: float -> float func:llAtan
71 ATAN2: float float -> float func:llAtan2
72 CAST_V2S: vect -> str
73 CAST_R2S: rot -> str
// 74 CAST_L2S: list -> str
// many of the following ops currently unimplemented
75 ADD_VV: vect + vect -> vect
76 SUB_VV: vect - vect -> vect
77 DOT_VV: vect * vect -> float
78 CROSS_VV: vect % vect -> vect
79 MUL_VF: vect * float -> vect
80 MUL_FV: float * vect -> vect
81 DIV_VF: vect / float -> vect
82 MUL_VR: vect * rot -> vect
83 DIV_VR: vect / rot -> vect
84 ADD_RR: rot + rot -> rot
85 SUB_RR: rot - rot -> rot
86 MUL_RR: rot * rot -> rot
87 DIV_RR: rot / rot -> rot
88 NEG_I: - int -> int
89 NEG_F: - float -> float
90 NEG_V: - vect -> vect
91 NEG_R: - rot -> rot
92 STRLEN: str -> int func:llStringLength
93 LISTLEN: list -> int func:llGetListLength
94 LIST2INT: list int -> int func:llList2Integer
95 LIST2FLOAT: list int -> float func:llList2Float
96 LIST2STR: list int -> str func:llList2String
97 LIST2KEY: list int -> key func:llList2Key
98 LIST2VEC: list int -> vect func:llList2Vector
99 LIST2ROT: list int -> vect func:llList2Rot
100 CAST_LIST2S: list -> str
// TODO - implement these
// Note that key and string must be distinct ops in order
// to ensure that list entries have the correct types.
101 CAST_I2L: int -> list
102 CAST_F2L: float -> list
103 CAST_S2L: str -> list
104 CAST_K2L: key -> list
105 CAST_V2L: vect -> list
106 CAST_R2L: rot -> list
// TODO - implement these!
107 CAST_S2I: str -> int
108 CAST_S2F: str -> float
109 EQ_KK: key == key -> int
// TODO - implement these!
110 CAST_S2V: str -> vect
111 CAST_S2R: str -> rot
112 ADD_LL: list + list -> list
// TODO: implement these!
// 113 ADD_LI: list + int -> list
// 114 ADD_LF: list + float -> list
// 115 ADD_LS: list + str -> list
// 116 ADD_LK: list + key -> list
// 117 ADD_LV: list + vect -> list
// 118 ADD_LR: list + rot -> list
119 NEQ_SS: str != str -> int
120 NEQ_KK: key != key -> int
121 SET_STATE: int ->
122 FLOOR: float -> int func:llFloor
123 CEIL: float -> int func:llCeil
124 ROUND: float -> int func:llRound
125 EQ_VV: vect == vect -> int // TODO
126 NEQ_VV: vect != vect -> int // TODO
127 EQ_RR: rot == rot -> int // TODO
128 NEQ_RR: rot != rot -> int // TODO
129 LIST_TYPE: list int -> int func:llGetListEntryType // TODO