You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// "The opcode is a two-digit number based only on the ones and tens digit of the value, that is, the opcode is the rightmost two digits of the first value in an instruction"
175
172
letop=this.OPS[temp_op.substr(-2,2)];
176
173
177
-
if(!op){
178
-
debugger;
179
-
}
180
-
181
174
letfull_op=temp_op.padStart(op.params+2,'0');
182
175
183
-
letmodes=this.sharedModes;
184
-
185
176
// "Parameter modes are single digits, one per parameter, read **right-to-left** from the opcode"
186
-
for(leti=op.params-1;i>=0;i--){
177
+
for(leti=op.params.length-1;i>=0;i--){
187
178
// [0,1,2,3,4,5]
188
179
// ^ ops.params = 6
189
180
// 5 -> 0 # |(5 - 6 + 1)| = | 0| = 0
@@ -192,23 +183,19 @@ class Computer {
192
183
// 2 -> 3 # |(2 - 6 + 1)| = |-3| = 3
193
184
// 1 -> 4 # |(1 - 6 + 1)| = |-4| = 4
194
185
// 0 -> 5 # |(0 - 6 + 1)| = |-5| = 5
195
-
modes[Math.abs(i-op.params+1)]=full_op[i];
186
+
op.params[Math.abs(i-op.params+1)]=full_op[i];
196
187
}
197
188
198
-
letrtn_obj={
199
-
...op,
200
-
modes,
201
-
};
202
189
letend=newDate();
203
190
this.parseOpTime+=(end-start);
204
-
returnrtn_obj;
191
+
returnop;
205
192
}
206
193
207
-
runOp({modes,params, fn, jumps, write }){
194
+
runOp({ params, fn, jumps, write }){
208
195
this.pointer++;
209
196
letvalues=[];
210
-
for(leti=0;i<params;i++){
211
-
letmode=modes[i];
197
+
for(leti=0;i<params.length;i++){
198
+
letmode=params[i];
212
199
letvalue=this.memory[this.pointer+i];
213
200
214
201
// Values can overflow existing memory. If so, value should be 0
@@ -277,7 +264,7 @@ class Computer {
277
264
* - I am running an op that does _not_ write to memory
278
265
* - Or if I am not at the last parameter in the op
0 commit comments