···101101///
102102/// **Return**. Moves R into P, popping the return stack. Skips any remaining slots
103103/// and fetches next instruction word.
104104-fn ret(self: *Computer) void {
105105- self.p.address = @bitCast(@as(u9, @intCast(self.return_stack.pop() & 0x1ff)));
104104+fn ret(c: *Computer) void {
105105+ c.p.address = @bitCast(@as(u9, @intCast(c.return_stack.pop() & 0x1ff)));
106106}
107107108108test ret {
···116116/// ex
117117///
118118/// **Execute**. Exchanges R and P, skips any remaining slots and fetches next instruction word.
119119-fn ex(self: *Computer) void {
120120- const current_address = self.p.address;
121121- self.p.address = Address.fromWord(self.return_stack.t);
122122- self.return_stack.t = current_address.toWord();
119119+fn ex(c: *Computer) void {
120120+ const current_address = c.p.address;
121121+ c.p.address = Address.fromWord(c.return_stack.t);
122122+ c.return_stack.t = current_address.toWord();
123123}
124124125125test ex {
···134134/// name ;
135135///
136136/// **Jump**. Sets P to destination address and fetches next instruction word.
137137-fn jump(self: *Computer) void {
138138- self.p.jump(self.slot, self.i);
137137+fn jump(c: *Computer) void {
138138+ c.p.jump(c.slot, c.i);
139139}
140140141141test "slot 0 jump" {
···190190/// Micronext. If R is zero, pops the return stack and continues with the next
191191/// opcode. If R is nonzero, decrements R by 1 and causes execution to continue
192192/// with slot 0 of the current instruction word without re-fetching the word.
193193-pub fn unext(self: *Computer) void {
194194- self.return_stack.t -= 1;
193193+pub fn unext(c: *Computer) void {
194194+ c.return_stack.t -= 1;
195195}
196196197197test unext {
···207207/// **Next**. If R is zero, pops the return stack and continues with the next
208208/// instruction word addressed by P. If R is nonzero, decrements R by 1 and
209209/// jumps
210210-pub fn next(self: *Computer) void {
211211- if (self.return_stack.t == 0) {
212212- _ = self.return_stack.pop();
210210+pub fn next(c: *Computer) void {
211211+ if (c.return_stack.t == 0) {
212212+ _ = c.return_stack.pop();
213213 } else {
214214- self.return_stack.t -= 1;
215215- self.p.jump(self.slot, self.i);
214214+ c.return_stack.t -= 1;
215215+ c.p.jump(c.slot, c.i);
216216 }
217217}
218218···231231/// if
232232///
233233/// **If**. If T is nonzero, continues with the next instruction word addressed by P. If T is zero, jumps
234234-pub fn _if(self: *Computer) void {
235235- if (self.data_stack.t == 0) {
236236- self.p.jump(self.slot, self.i);
234234+pub fn _if(c: *Computer) void {
235235+ if (c.data_stack.t == 0) {
236236+ c.p.jump(c.slot, c.i);
237237 }
238238}
239239···253253///
254254/// Minus-if. If T is negative (T17 set), continues with the next instruction
255255/// word addressed by P. If T is positive, jumps
256256-pub fn minus_if(self: *Computer) void {
257257- if (self.data_stack.t >= 0) {
258258- self.p.jump(self.slot, self.i);
256256+pub fn minus_if(c: *Computer) void {
257257+ if (c.data_stack.t >= 0) {
258258+ c.p.jump(c.slot, c.i);
259259 }
260260}
261261···274274/// @p
275275///
276276/// Pushes data stack, reads [P] into T, and increments P
277277-pub fn fetchP(self: *Computer) void {
278278- self.data_stack.push(self.fetch(self.p.address));
279279- self.p.increment();
277277+pub fn fetchP(c: *Computer) void {
278278+ c.data_stack.push(c.fetch(c.p.address));
279279+ c.p.increment();
280280}
281281282282test fetchP {
···292292/// @+
293293///
294294/// **Fetch-plus**. Pushes data stack, reads [A] into T, and increments A
295295-pub fn fetchPlus(self: *Computer) void {
296296- var address = Address.fromWord(self.a);
297297- self.data_stack.push(self.fetch(address));
295295+pub fn fetchPlus(c: *Computer) void {
296296+ var address = Address.fromWord(c.a);
297297+ c.data_stack.push(c.fetch(address));
298298 address.local +%= 1;
299299- self.a = address.toWord();
299299+ c.a = address.toWord();
300300}
301301302302test fetchPlus {
···344344/// !p
345345///
346346/// **Store-P**. Writes T into [P], pops the data stack, and increments P
347347-pub fn storeP(self: *Computer) void {
348348- self.store(self.p.address, self.data_stack.pop());
349349- self.p.increment();
347347+pub fn storeP(c: *Computer) void {
348348+ c.store(c.p.address, c.data_stack.pop());
349349+ c.p.increment();
350350}
351351352352test storeP {
···363363/// !+
364364///
365365/// **Store-plus**. Writes T into [A], pops the data stack, and increments A
366366-pub fn storePlus(self: *Computer) void {
367367- var address = Address.fromWord(self.a);
368368- self.store(address, self.data_stack.pop());
366366+pub fn storePlus(c: *Computer) void {
367367+ var address = Address.fromWord(c.a);
368368+ c.store(address, c.data_stack.pop());
369369370370 address.local +%= 1;
371371- self.a = address.toWord();
371371+ c.a = address.toWord();
372372}
373373374374test storePlus {
···385385/// !b
386386///
387387/// **Store-B**. Writes T into [B] and pops the data stack.
388388-pub fn storeB(self: *Computer) void {
389389- self.store(Address.fromWord(self.b), self.data_stack.pop());
388388+pub fn storeB(c: *Computer) void {
389389+ c.store(Address.fromWord(c.b), c.data_stack.pop());
390390}
391391392392test storeB {
···402402/// !
403403///
404404/// **Store**. Writes T into [A] and pops the data stack.
405405-pub fn store(self: *Computer) void {
406406- self.store(Address.fromWord(self.a), self.data_stack.pop());
405405+pub fn store(c: *Computer) void {
406406+ c.store(Address.fromWord(c.a), c.data_stack.pop());
407407}
408408409409test store {
···419419/// 2*
420420///
421421/// **Two-Star**. Shifts T left one bit logically (shifts zero into T0, discards T17) thus multiplying a signed or unsigned value by two.
422422-pub fn shl(self: *Computer) void {
423423- self.data_stack.t <<= 1;
422422+pub fn shl(c: *Computer) void {
423423+ c.data_stack.t <<= 1;
424424}
425425426426test shl {
···434434/// 2/
435435///
436436/// **Two-Slash**. Shifts T right one bit arithmetically (propagates T17 by leaving it unchanged; discards T0) thus dividing a signed value by two and discarding the positive remainder.
437437-pub fn shr(self: *Computer) void {
438438- self.data_stack.t >>= 1;
437437+pub fn shr(c: *Computer) void {
438438+ c.data_stack.t >>= 1;
439439}
440440441441test shr {
···449449/// inv
450450///
451451/// **Invert**. Inverts each bit of T, replacing T with its ones complement.
452452-pub fn inv(self: *Computer) void {
453453- self.data_stack.t = ~self.data_stack.t;
452452+pub fn inv(c: *Computer) void {
453453+ c.data_stack.t = ~c.data_stack.t;
454454}
455455456456test inv {
···468468/// +
469469///
470470/// **Plus**. Replaces T with the twos complement sum of S and T. Pops data stack into S. This instruction is affected in Extended Arithmetic Mode, becoming **Add with carry**. Includes the latched carry in the sum, and latches the carry out from bit 17.
471471-pub fn add(self: *Computer) void {
471471+pub fn add(c: *Computer) void {
472472 var result: f18.Word = 0;
473473- if (self.p.extended_arithmetic) {
474474- result, self.carry = @addWithOverflow(self.data_stack.s + self.carry, self.data_stack.pop());
473473+ if (c.p.extended_arithmetic) {
474474+ result, c.carry = @addWithOverflow(c.data_stack.s + c.carry, c.data_stack.pop());
475475 } else {
476476- result = self.data_stack.s + self.data_stack.pop();
476476+ result = c.data_stack.s + c.data_stack.pop();
477477 }
478478- self.data_stack.push(result);
478478+ c.data_stack.push(result);
479479}
480480481481test add {
···508508/// and
509509///
510510/// Replaces T with the Boolean AND of S and T. Pops data stack.
511511-pub fn _and(self: *Computer) void {
512512- self.data_stack.push(self.data_stack.s & self.data_stack.pop());
511511+pub fn _and(c: *Computer) void {
512512+ c.data_stack.push(c.data_stack.s & c.data_stack.pop());
513513}
514514515515test _and {
···524524/// xor
525525///
526526/// **Exclusive Or**. Replaces T with the Boolean XOR of S and T. Pops data stack.
527527-pub fn xor(self: *Computer) void {
528528- self.data_stack.push(self.data_stack.s ^ self.data_stack.pop());
527527+pub fn xor(c: *Computer) void {
528528+ c.data_stack.push(c.data_stack.s ^ c.data_stack.pop());
529529}
530530531531test xor {
···540540/// drop
541541///
542542/// Drops the top item from the data stack by copying S into T and popping the data stack.
543543-pub fn drop(self: *Computer) void {
544544- _ = self.data_stack.pop();
543543+pub fn drop(c: *Computer) void {
544544+ _ = c.data_stack.pop();
545545}
546546547547test drop {
···557557/// dup
558558///
559559/// Duplicates the top item on the data stack by pushing the data stack and copying T into S.
560560-pub fn dup(self: *Computer) void {
561561- self.data_stack.push(self.data_stack.t);
560560+pub fn dup(c: *Computer) void {
561561+ c.data_stack.push(c.data_stack.t);
562562}
563563564564test dup {
···573573/// r>
574574///
575575/// Moves R into T, popping the return stack and pushing the data stack.
576576-pub fn pop(self: *Computer) void {
577577- self.data_stack.push(self.return_stack.pop());
576576+pub fn pop(c: *Computer) void {
577577+ c.data_stack.push(c.return_stack.pop());
578578}
579579580580test pop {
···590590///
591591/// Makes a copy of S on top of the data stack by pushing S onto the stack,
592592/// moving T into S, and replacing T by the previous value of S.
593593-pub fn over(self: *Computer) void {
594594- self.data_stack.push(self.data_stack.s);
593593+pub fn over(c: *Computer) void {
594594+ c.data_stack.push(c.data_stack.s);
595595}
596596597597test over {
···611611/// a
612612///
613613/// Fetches the contents of register A into T, pushing the data stack.
614614-pub fn a(self: *Computer) void {
615615- self.data_stack.push(self.a);
614614+pub fn a(c: *Computer) void {
615615+ c.data_stack.push(c.a);
616616}
617617618618test a {
···631631/// >r
632632///
633633/// Moves T into R, pushing the return stack and popping the data stack.
634634-pub fn push(self: *Computer) void {
635635- self.return_stack.push(self.data_stack.pop());
634634+pub fn push(c: *Computer) void {
635635+ c.return_stack.push(c.data_stack.pop());
636636}
637637638638test push {
···647647/// b!
648648///
649649/// **B-Store**. Stores T into register B, popping the data stack.
650650-pub fn bStore(self: *Computer) void {
651651- self.b = @intCast(self.data_stack.pop() & 0x1ff);
650650+pub fn bStore(c: *Computer) void {
651651+ c.b = @intCast(c.data_stack.pop() & 0x1ff);
652652}
653653654654test bStore {
···663663/// a!
664664///
665665/// **A-Store**. Stores T into register A, popping the data stack.
666666-pub fn aStore(self: *Computer) void {
667667- self.a = self.data_stack.pop();
666666+pub fn aStore(c: *Computer) void {
667667+ c.a = c.data_stack.pop();
668668}
669669670670test aStore {