From 982fe968dd13a3804993913085e1fc40848ba786 Mon Sep 17 00:00:00 2001 From: Miles Date: Fri, 16 Oct 2015 09:59:33 -0400 Subject: [PATCH 1/5] load Got load working, long way to go --- distrib/globals.js | 1 + distrib/host/control.js | 1 + distrib/os/shell.js | 21 +++++++++++++++++++++ index.html | 3 ++- source/globals.ts | 1 + source/host/control.ts | 2 +- source/os/shell.ts | 25 ++++++++++++++++++++++++- 7 files changed, 51 insertions(+), 3 deletions(-) diff --git a/distrib/globals.js b/distrib/globals.js index e7631b8..6e77247 100644 --- a/distrib/globals.js +++ b/distrib/globals.js @@ -18,6 +18,7 @@ var TIMER_IRQ = 0; // Pages 23 (timer), 9 (interrupts), and 561 (interrupt prior var KEYBOARD_IRQ = 1; var commandHistory = []; var globalCanvasChangeBoolean = false; +var _ProgramInput = document.getElementById("taProgramInput"); // // Global Variables // TODO: Make a global object and use that instead of the "_" naming convention in the global namespace. diff --git a/distrib/host/control.js b/distrib/host/control.js index 2c41979..57174c2 100644 --- a/distrib/host/control.js +++ b/distrib/host/control.js @@ -37,6 +37,7 @@ var TSOS; // Clear the log text box. // Use the TypeScript cast to HTMLInputElement document.getElementById("taHostLog").value = ""; + _ProgramInput = document.getElementById("taProgramInput"); // Set focus on the start button. // Use the TypeScript cast to HTMLInputElement document.getElementById("btnStartOS").focus(); diff --git a/distrib/os/shell.js b/distrib/os/shell.js index 446a406..7e5d7da 100644 --- a/distrib/os/shell.js +++ b/distrib/os/shell.js @@ -66,6 +66,8 @@ var TSOS; this.commandList[this.commandList.length] = sc; // ps - list the running processes and their IDs // kill - kills the specified process id. + sc = new TSOS.ShellCommand(this.shellLoad, "load", "Loads the hex characters in the program input"); + this.commandList[this.commandList.length] = sc; // // Display the initial prompt. this.putPrompt(); @@ -295,6 +297,25 @@ var TSOS; Shell.prototype.shellBSOD = function (args) { globalCanvasChangeBoolean = true; }; + Shell.prototype.shellLoad = function () { + var userText = _ProgramInput.value.toString(); + var isValid = true; + for (var i = 0; i < userText.length; i++) { + var char = userText.charCodeAt(i); + if ((char >= 48 && char <= 57) || (char >= 65 && char <= 70) || (char == 32)) { + isValid = true; + } + else { + isValid = false; + } + } + if (isValid) { + _StdOut.putText("Program validated"); + } + else { + _StdOut.putText("Program not validated. Must use spaces, numbers 0-9 and A-F only"); + } + }; return Shell; })(); TSOS.Shell = Shell; diff --git a/index.html b/index.html index ed356b7..961b042 100755 --- a/index.html +++ b/index.html @@ -41,9 +41,10 @@ } } - + diff --git a/source/globals.ts b/source/globals.ts index 8616dad..fce1832 100644 --- a/source/globals.ts +++ b/source/globals.ts @@ -23,6 +23,7 @@ const KEYBOARD_IRQ: number = 1; var commandHistory = []; var globalCanvasChangeBoolean = false; +var _ProgramInput = document.getElementById("taProgramInput"); // diff --git a/source/host/control.ts b/source/host/control.ts index c5dec8b..3c165bc 100644 --- a/source/host/control.ts +++ b/source/host/control.ts @@ -42,7 +42,7 @@ module TSOS { // Clear the log text box. // Use the TypeScript cast to HTMLInputElement ( document.getElementById("taHostLog")).value=""; - + _ProgramInput =document.getElementById("taProgramInput"); // Set focus on the start button. // Use the TypeScript cast to HTMLInputElement ( document.getElementById("btnStartOS")).focus(); diff --git a/source/os/shell.ts b/source/os/shell.ts index 1417ca5..eb665ac 100644 --- a/source/os/shell.ts +++ b/source/os/shell.ts @@ -110,7 +110,10 @@ module TSOS { // ps - list the running processes and their IDs // kill - kills the specified process id. - + sc = new ShellCommand(this.shellLoad, + "load", + "Loads the hex characters in the program input"); + this.commandList[this.commandList.length] = sc; // // Display the initial prompt. this.putPrompt(); @@ -352,5 +355,25 @@ module TSOS { public shellBSOD(args) { globalCanvasChangeBoolean = true; } + public shellLoad () { + var userText = _ProgramInput.value.toString(); + var isValid = true; + for( var i = 0; i< userText.length; i++) { + var char = userText.charCodeAt(i); + if ((char >= 48 && char <= 57) || (char >= 65 && char <= 70) || (char == 32)) { + isValid = true; + } else { + isValid = false; + } + } + if(isValid) { + _StdOut.putText("Program validated"); + + + } else { + _StdOut.putText("Program not validated. Must use spaces, numbers 0-9 and A-F only"); + } + + } } } From c5d93b5b9d54d6cd2374fc762784c410c8cf0803 Mon Sep 17 00:00:00 2001 From: Miles Date: Tue, 20 Oct 2015 17:14:13 -0400 Subject: [PATCH 2/5] OP Codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I am pretty sure I have op codes working. I can’t get the memory updater to work though, will commit again when I can do this --- distrib/globals.js | 4 + distrib/host/cpu.js | 130 +++++++++++++++++++++++++++++ distrib/os/console.js | 13 +++ distrib/os/deviceDriverKeyboard.js | 4 + distrib/os/memory.js | 27 ++++++ source/globals.ts | 6 +- source/host/cpu.ts | 130 ++++++++++++++++++++++++++++- source/host/memory.ts | 22 +++++ source/os/console.ts | 15 +++- source/os/deviceDriverKeyboard.ts | 4 + 10 files changed, 352 insertions(+), 3 deletions(-) create mode 100644 distrib/os/memory.js create mode 100644 source/host/memory.ts diff --git a/distrib/globals.js b/distrib/globals.js index 6e77247..6c7dbd2 100644 --- a/distrib/globals.js +++ b/distrib/globals.js @@ -40,6 +40,10 @@ var _KernelBuffers = null; // when clearly 'any' is not what we want. There is l // Standard input and output var _StdIn; // Same "to null or not to null" issue as above. var _StdOut; +var _MemoryArrayUser = null; +var _MemoryArrayIndex = null; +var _MainMemoryElement = null; +var _MemoryArray = Array.apply(null, new Array(256).map)(String.prototype.valueOf(), "00"); // UI var _Console; var _OsShell; diff --git a/distrib/host/cpu.js b/distrib/host/cpu.js index 26fdc3c..965d24d 100644 --- a/distrib/host/cpu.js +++ b/distrib/host/cpu.js @@ -42,6 +42,136 @@ var TSOS; _Kernel.krnTrace('CPU cycle'); // TODO: Accumulate CPU usage and profiling statistics here. // Do the real work here. Be sure to set this.isExecuting appropriately. + this.OPCommands(_MemoryArray[this.PC]); + }; + Cpu.prototype.loadInits = function (PC, Acc, Xreg, Yreg, Zflag) { + this.PC = PC; + this.Acc = Acc; + this.Xreg = Yreg; + this.Zflag = Zflag; + }; + Cpu.prototype.OPCommands = function (givenCommand) { + switch (givenCommand) { + case "A9": { + this.Acc = parseInt("0x" + (_MemoryArray[this.PC + 1])); + this.PC = this.PC + 2; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "AD": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + this.Acc = parseInt("0x" + _MemoryArray[this.PC]); + this.PC = PreOP + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "8D": { + var memoryPointer = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + if (this.Acc < 16) { + _MemoryArray[memoryPointer] = "0" + this.Acc; + } + else { + _MemoryArray[memoryPointer] = this.Acc; + } + this.PC = this.PC + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "6D": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + this.Acc = this.Acc + parseInt("0x" + _MemoryArray[this.PC]); + this.PC = PreOP + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "A2": { + this.Xreg = parseInt("0x" + (_MemoryArray[this.PC + 1])); + this.PC = this.PC + 2; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "AE": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + this.Xreg = parseInt("0x" + _MemoryArray[this.PC]); + _MemoryArrayUser.memoryUpdater(); + break; + } + case "A0": { + this.Yreg = parseInt("0x" + (_MemoryArray[this.PC + 1])); + this.PC = this.PC + 2; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "AC": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + this.Yreg = parseInt("0x" + _MemoryArray[this.PC]); + this.PC = PreOP + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "EA": { + this.PC = this.PC + 1; + break; + } + case "00": { + this.isExecuting = false; + _MemoryArrayUser.memoryUpdater(); + document.getElementById("btnHalt").disabled = true; + break; + } + case "EC": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + var CompareVar = parseInt("0x" + _MemoryArray[this.PC]); + if (CompareVar = this.Xreg) { + this.Zflag = 1; + } + this.PC = PreOP + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "D0": { + if (this.Zflag == 0) { + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + } + else { + this.PC = this.PC + 1; + } + _MemoryArrayUser.memoryUpdater(); + break; + } + case "EE": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + var adder = parseInt("0x" + _MemoryArray[this.PC]); + adder = adder + 0x0001; + _MemoryArray[this.PC] = adder.toString().replace("0x", ""); + _MemoryArrayUser.memoryUpdater(); + break; + } + case "FF": { + if (this.Xreg == 0x01) { + _DrawingContext.putText(this.Yreg); + _DrawingContext.advanceLine(); + } + if (this.Xreg == 0x02) { + _DrawingContext.putText(this.Yreg.toString()); + _DrawingContext.advanceLine(); + } + _MemoryArrayUser.memoryUpdater(); + break; + } + default: { + _StdOut.putText("This does not work " + _MemoryArray[this.PC]); + this.isExecuting = false; + _MemoryArrayUser.memoryUpdater(); + break; + } + } }; return Cpu; })(); diff --git a/distrib/os/console.js b/distrib/os/console.js index 8162cc2..a63866e 100644 --- a/distrib/os/console.js +++ b/distrib/os/console.js @@ -50,6 +50,11 @@ var TSOS; tabIncrease = tabIncrease + 4; alert(chr); } + else if (chr === String.fromCharCode(8)) { + var characterRemoval = this.buffer.charAt(this.buffer.length - 1); + this.buffer = this.buffer.charAt(this.buffer.length - 1); + this.Backspace(characterRemoval); + } else { // This is a "normal" character, so ... // ... draw it on the screen... @@ -96,6 +101,14 @@ var TSOS; _FontHeightMargin; } }; + Console.prototype.Backspace = function (char) { + var characterLength = _DrawingContext.measureText(this.currentFont, this.currentFontSize, char); + var verticalHeight = _DefaultFontSize + _FontHeightMargin; + _DrawingContext.clearRect(this.currentXPosition - characterLength, ((this.currentYPosition - verticalHeight) + 5), characterLength, verticalHeight); + if (this.currentXPosition > 0) { + this.currentXPosition = this.currentXPosition - characterLength; + } + }; return Console; })(); TSOS.Console = Console; diff --git a/distrib/os/deviceDriverKeyboard.js b/distrib/os/deviceDriverKeyboard.js index 0e32501..6cfa553 100644 --- a/distrib/os/deviceDriverKeyboard.js +++ b/distrib/os/deviceDriverKeyboard.js @@ -34,6 +34,10 @@ var TSOS; _Kernel.krnTrace("Key code:" + keyCode + " shifted:" + isShifted); var chr = ""; // Check to see if we even want to deal with the key that was pressed. + if (keyCode == 8) { + chr = String.fromCharCode(keyCode); + _KernelInputQueue.enqueue(chr); + } if (((keyCode >= 65) && (keyCode <= 90)) || ((keyCode >= 97) && (keyCode <= 123))) { // Determine the character we want to display. diff --git a/distrib/os/memory.js b/distrib/os/memory.js new file mode 100644 index 0000000..2072719 --- /dev/null +++ b/distrib/os/memory.js @@ -0,0 +1,27 @@ +/** + * Created by thorwald on 10/17/15. + */ +var TSOS; +(function (TSOS) { + var memory = (function () { + function memory() { + } + memory.prototype.memory = function () { + var plusone = 0; + }; + memory.prototype.load = function (memoryItem) { + _MemoryArray[_MemoryArrayIndex] = memoryItem; + _MemoryArrayIndex++; + this.memoryUpdater(); + }; + memory.prototype.memoryUpdater = function () { + var i = 0; + _MainMemoryElement = ""; + for (i = 0; i < _MemoryArray.length; i++) { + _MainMemoryElement = _MainMemoryElement + _MemoryArray[i] + " "; + } + }; + return memory; + })(); + TSOS.memory = memory; +})(TSOS || (TSOS = {})); diff --git a/source/globals.ts b/source/globals.ts index fce1832..e6f9148 100644 --- a/source/globals.ts +++ b/source/globals.ts @@ -30,6 +30,7 @@ var _ProgramInput = document.getElementById("taProgramInput // Global Variables // TODO: Make a global object and use that instead of the "_" naming convention in the global namespace. // + var _CPU: TSOS.Cpu; // Utilize TypeScript's type annotation system to ensure that _CPU is an instance of the Cpu class. var _OSclock: number = 0; // Page 23. @@ -53,7 +54,10 @@ var _KernelBuffers: any[] = null; // when clearly 'any' is not what we want. T // Standard input and output var _StdIn; // Same "to null or not to null" issue as above. var _StdOut; - +var _MemoryArrayUser = null; +var _MemoryArrayIndex = null; +var _MainMemoryElement = null; +var _MemoryArray = Array.apply(null, new Array(256).map)(String.prototype.valueOf(),"00"); // UI var _Console: TSOS.Console; var _OsShell: TSOS.Shell; diff --git a/source/host/cpu.ts b/source/host/cpu.ts index 3dc16ce..69dc75e 100644 --- a/source/host/cpu.ts +++ b/source/host/cpu.ts @@ -1,4 +1,5 @@ -/// +/// +/// /* ------------ CPU.ts @@ -41,6 +42,133 @@ module TSOS { _Kernel.krnTrace('CPU cycle'); // TODO: Accumulate CPU usage and profiling statistics here. // Do the real work here. Be sure to set this.isExecuting appropriately. + this.OPCommands(_MemoryArray[this.PC]); + } + public loadInits(PC, Acc, Xreg, Yreg, Zflag) + { + this.PC = PC; + this.Acc = Acc; + this.Xreg = Yreg; + this.Zflag = Zflag; + } + public OPCommands(givenCommand){ + switch (givenCommand) { + case "A9": { + this.Acc = parseInt("0x" + (_MemoryArray[this.PC + 1])); + this.PC = this.PC + 2; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "AD": { + var PreOP = this.PC; + this.PC = parseInt("0x"+_MemoryArray[this.PC+2]+_MemoryArray[this.PC+1]); + this.Acc = parseInt("0x" + _MemoryArray[this.PC]); + this.PC = PreOP + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "8D": { + var memoryPointer = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + if(this.Acc < 16) { + _MemoryArray[memoryPointer] = "0" + this.Acc; + } + else { + _MemoryArray[memoryPointer] = this.Acc; + } + this.PC = this.PC + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "6D": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + this.Acc = this.Acc + parseInt("0x" + _MemoryArray[this.PC]); + this.PC = PreOP +3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "A2": { + this.Xreg = parseInt("0x" + (_MemoryArray[this.PC + 1])); + this.PC = this.PC + 2; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "AE": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + this.Xreg = parseInt("0x" + _MemoryArray[this.PC]); + _MemoryArrayUser.memoryUpdater(); + break; + } + case "A0": { + this.Yreg = parseInt("0x" + (_MemoryArray[this.PC + 1])); + this.PC = this.PC + 2; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "AC": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + this.Yreg = parseInt("0x" + _MemoryArray[this.PC]); + this.PC = PreOP + 3; + _MemoryArrayUser.cpu.memoryUpdater(); + break; + } + case "EA": { + this.PC = this.PC + 1; + break; + } + case "00": { + this.isExecuting = false; + _MemoryArrayUser.memoryUpdater(); + document.getElementById("btnHalt").disabled = true; + break; + } + case "EC": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + var CompareVar = parseInt("0x" + _MemoryArray[this.PC]); + if(CompareVar = this.Xreg) { + this.Zflag = 1; + } + this.PC = PreOP + 3; + _MemoryArrayUser.memoryUpdater(); + break; + } + case "D0": { + if(this.Zflag == 0) { + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + } else { + this.PC = this.PC + 1; + } _MemoryArrayUser.memoryUpdater(); + break; + } + case "EE": { + var PreOP = this.PC; + this.PC = parseInt("0x" + _MemoryArray[this.PC + 2] + _MemoryArray[this.PC + 1]); + var adder = parseInt("0x" + _MemoryArray[this.PC]); + adder = adder + 0x0001; + _MemoryArray[this.PC] = adder.toString().replace("0x",""); + _MemoryArrayUser.memoryUpdater(); + break; + } + case "FF": { + if(this.Xreg == 0x01) { + _DrawingContext.putText(this.Yreg); + _DrawingContext.advanceLine(); + } if(this.Xreg == 0x02) { + _DrawingContext.putText(this.Yreg.toString()); + _DrawingContext.advanceLine(); + } _MemoryArrayUser.memoryUpdater(); + break; + } + default : { + _StdOut.putText("This does not work " + _MemoryArray[this.PC]); + this.isExecuting = false; + _MemoryArrayUser.memoryUpdater(); + break; + } + } } } } diff --git a/source/host/memory.ts b/source/host/memory.ts new file mode 100644 index 0000000..f2f7dc1 --- /dev/null +++ b/source/host/memory.ts @@ -0,0 +1,22 @@ +/** + * Created by thorwald on 10/17/15. + */ +module TSOS { + export class memory + { + public memory() { + var plusone = 0; + } + public load(memoryItem) { + _MemoryArray[_MemoryArrayIndex] = memoryItem; + _MemoryArrayIndex++; + this.memoryUpdater(); + } + public memoryUpdater() { + var i = 0; + _MainMemoryElement = ""; + for(i = 0; i < _MemoryArray.length; i++){ + _MainMemoryElement = _MainMemoryElement + _MemoryArray[i] + " "; + } + } +} \ No newline at end of file diff --git a/source/os/console.ts b/source/os/console.ts index 122b637..a89a5fa 100644 --- a/source/os/console.ts +++ b/source/os/console.ts @@ -49,7 +49,12 @@ module TSOS { } else if ((chr === String.fromCharCode(tabIncrease))) { tabIncrease = tabIncrease+4; alert(chr); - } else { + } else if(chr === String.fromCharCode(8)) { + var characterRemoval = this.buffer.charAt(this.buffer.length - 1) + this.buffer = this.buffer.charAt(this.buffer.length - 1); + this.Backspace(characterRemoval); + } + else { // This is a "normal" character, so ... // ... draw it on the screen... this.putText(chr); @@ -100,5 +105,13 @@ module TSOS { } } + public Backspace(char) { + var characterLength = _DrawingContext.measureText(this.currentFont, this.currentFontSize, char); + var verticalHeight = _DefaultFontSize + _FontHeightMargin; + _DrawingContext.clearRect(this.currentXPosition - characterLength, ((this.currentYPosition - verticalHeight) + 5 ), characterLength, verticalHeight); + if(this.currentXPosition > 0) { + this.currentXPosition = this.currentXPosition - characterLength; + } + } } } diff --git a/source/os/deviceDriverKeyboard.ts b/source/os/deviceDriverKeyboard.ts index b738027..3a93c2f 100644 --- a/source/os/deviceDriverKeyboard.ts +++ b/source/os/deviceDriverKeyboard.ts @@ -33,6 +33,10 @@ module TSOS { _Kernel.krnTrace("Key code:" + keyCode + " shifted:" + isShifted); var chr = ""; // Check to see if we even want to deal with the key that was pressed. + if (keyCode == 8) { + chr = String.fromCharCode(keyCode); + _KernelInputQueue.enqueue(chr); + } if (((keyCode >= 65) && (keyCode <= 90)) || // A..Z ((keyCode >= 97) && (keyCode <= 123)) ){ // a..z From 372cdd54f3f819e7a06d72f18effdb8704434784 Mon Sep 17 00:00:00 2001 From: Miles Date: Thu, 22 Oct 2015 18:01:42 -0400 Subject: [PATCH 3/5] I am giving up at this point I will talk to you tomorrow but this is not even running after I have added the op codes so I have no idea --- distrib/globals.js | 2 +- distrib/host/cpu.js | 12 ++++++++++-- distrib/host/memory.js | 28 ++++++++++++++++++++++++++++ index.html | 13 ++++++++++--- source/globals.ts | 2 +- source/host/cpu.ts | 14 +++++++++++--- source/host/memory.ts | 9 ++++++--- 7 files changed, 67 insertions(+), 13 deletions(-) create mode 100644 distrib/host/memory.js diff --git a/distrib/globals.js b/distrib/globals.js index 6c7dbd2..4584085 100644 --- a/distrib/globals.js +++ b/distrib/globals.js @@ -40,7 +40,7 @@ var _KernelBuffers = null; // when clearly 'any' is not what we want. There is l // Standard input and output var _StdIn; // Same "to null or not to null" issue as above. var _StdOut; -var _MemoryArrayUser = null; +// var _MemoryArrayUser = new TSOS.memory(); var _MemoryArrayIndex = null; var _MainMemoryElement = null; var _MemoryArray = Array.apply(null, new Array(256).map)(String.prototype.valueOf(), "00"); diff --git a/distrib/host/cpu.js b/distrib/host/cpu.js index 965d24d..fca7107 100644 --- a/distrib/host/cpu.js +++ b/distrib/host/cpu.js @@ -1,4 +1,5 @@ -/// +/// +/// /* ------------ CPU.ts @@ -44,6 +45,14 @@ var TSOS; // Do the real work here. Be sure to set this.isExecuting appropriately. this.OPCommands(_MemoryArray[this.PC]); }; + Cpu.prototype.updateConsole = function () { + _MainMemoryElement = _MainMemoryElement + "\n" + "\n"; + _MainMemoryElement = _MainMemoryElement + "PC: " + this.PC + "\n"; + _MainMemoryElement = _MainMemoryElement + "Acc: " + this.Acc + "\n"; + _MainMemoryElement = _MainMemoryElement + "Xreg: " + this.Xreg + "\n"; + _MainMemoryElement = _MainMemoryElement + "Yreg: " + this.Yreg + "\n"; + _MainMemoryElement = _MainMemoryElement + "Zflag: " + this.Zflag + "\n"; + }; Cpu.prototype.loadInits = function (PC, Acc, Xreg, Yreg, Zflag) { this.PC = PC; this.Acc = Acc; @@ -120,7 +129,6 @@ var TSOS; case "00": { this.isExecuting = false; _MemoryArrayUser.memoryUpdater(); - document.getElementById("btnHalt").disabled = true; break; } case "EC": { diff --git a/distrib/host/memory.js b/distrib/host/memory.js new file mode 100644 index 0000000..5e7f37a --- /dev/null +++ b/distrib/host/memory.js @@ -0,0 +1,28 @@ +/** + * Created by thorwald on 10/17/15. + */ +/// +var TSOS; +(function (TSOS) { + var memory = (function () { + function memory() { + } + memory.prototype.memory = function () { + var plusone = 0; + }; + memory.prototype.load = function (memoryItem) { + _MemoryArray[_MemoryArrayIndex] = memoryItem; + _MemoryArrayIndex++; + this.memoryUpdater(); + }; + memory.prototype.memoryUpdater = function () { + var i = 0; + _MainMemoryElement = ""; + for (i = 0; i < _MemoryArray.length; i++) { + _MainMemoryElement = _MainMemoryElement + _MemoryArray[i] + " "; + } + }; + return memory; + })(); + TSOS.memory = memory; +})(TSOS || (TSOS = {})); diff --git a/index.html b/index.html index 961b042..48903f9 100755 --- a/index.html +++ b/index.html @@ -41,10 +41,10 @@ } } - +--> @@ -91,7 +91,6 @@ fillstyle="Blue"> -
+