From 6826d32ca70ec6b6e751813bb595b6ade288cb69 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 23 May 2023 13:36:35 -0500 Subject: add random non-overlapping ranges in core --- src/vm/vm.js | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/vm/vm.js (limited to 'src/vm/vm.js') diff --git a/src/vm/vm.js b/src/vm/vm.js new file mode 100644 index 0000000..1ec890b --- /dev/null +++ b/src/vm/vm.js @@ -0,0 +1,36 @@ +'use strict'; + + +const { Core } = require('./core.js'); +const { + DAT, + MOV, ADD, SUB, CMP, SLT, + JMP, JMZ, JMN, DJN, SPL, +} = require('./instruction.js'); + + +class Warrior { + constructor(start) { + this.queue = [start]; + } + + isDead() { return (this.queue.length === 0); } + + append(heads) { + this.queue.push(...heads); + } + + next() { + const pc = this.queue[0]; + this.queue = this.queue.slice(1); + return next; + } +}; + + +class RedcodeVm { + constructor(coresize, warriors) { + this.core = new Core(coresize); + + } +}; -- cgit v1.2.1