/** * The driver program for the 4bit virtual machine. * Commandline options: * -d specifies debug mode, which will print the state of the machine at each * executiion step * [filename] filepath of the the prog to run * * @author mbk * @version 1 */ public class VMDriver { /** * main driver program for the VM. * @param args The commandline arguments */ public static void main(String[] args) { String usageString = "usage: java VMDriver [-d]"; try { if (args.length != 1 && args.length != 2) { System.err.println(usageString); return; } VM vm = new VM(args[0]); if (args.length == 2 && args[1].equals("-d")) { vm.debugModeOn(); } while (vm.isRunning()) { vm.step(); } } catch (Exception e) { System.err.println(e); } } }