From 15323007750e0f0f7c36a6a6fa01ad1d303a4a16 Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 23 May 2023 14:53:53 -0500 Subject: implement basic vm runner --- src/main.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main.js (limited to 'src/main.js') diff --git a/src/main.js b/src/main.js new file mode 100644 index 0000000..ec74ee7 --- /dev/null +++ b/src/main.js @@ -0,0 +1,23 @@ +'use strict'; + +const process = require('node:process'); +const fs = require('node:fs'); + +const { assemble } = require('./parser/parser.js'); +const { RedcodeVm } = require('./vm/vm.js'); + + +const files = process.argv.slice(2); +if (files.length === 0) { + console.log("no input files provided!"); +} + + +const warriors = files.map(fname => { + const source = fs.readFileSync(fname, 'utf8'); + return assemble(source); +}); + + +const vm = new RedcodeVm(8000, warriors); +console.log(vm.run(100000)); -- cgit v1.2.1