├── .gitignore ├── BuiltInChips ├── pom.xml └── src │ └── main │ └── java │ └── builtInChips │ ├── ALU.java │ ├── ARegister.java │ ├── Add16.java │ ├── And.java │ ├── Bit.java │ ├── DFF.java │ ├── DMux.java │ ├── DMux4Way.java │ ├── DMux8Way.java │ ├── DRegister.java │ ├── FullAdder.java │ ├── HalfAdder.java │ ├── Inc16.java │ ├── Keyboard.java │ ├── Mux.java │ ├── Mux4Way16.java │ ├── Mux8Way16.java │ ├── Nand.java │ ├── Not.java │ ├── Not16.java │ ├── Or.java │ ├── Or8Way.java │ ├── PC.java │ ├── RAM.java │ ├── RAM16K.java │ ├── RAM4K.java │ ├── RAM512.java │ ├── RAM64.java │ ├── RAM8.java │ ├── ROM32K.java │ ├── Register.java │ ├── RegisterWithGUI.java │ ├── Screen.java │ └── Xor.java ├── BuiltInVMCode ├── pom.xml └── src │ └── main │ └── java │ └── builtInVMCode │ ├── JackOSClass.java │ ├── Jack_Array.java │ ├── Jack_Keyboard.java │ ├── Jack_Math.java │ ├── Jack_Memory.java │ ├── Jack_Output.java │ ├── Jack_Screen.java │ ├── Jack_String.java │ └── Jack_Sys.java ├── CPUEmulator ├── pom.xml └── src │ └── main │ ├── java │ └── CPUEmulatorMain.java │ └── resources │ ├── about.html │ ├── git.properties │ └── usage.html ├── ChangeLog.txt ├── CompilersPackage ├── pom.xml └── src │ └── main │ └── java │ └── Hack │ ├── Assembler │ ├── AssemblerException.java │ ├── AssemblyLineTokenizer.java │ ├── HackAssembler.java │ ├── HackAssemblerEvent.java │ ├── HackAssemblerGUI.java │ └── HackAssemblerTranslator.java │ └── VirtualMachine │ ├── HVMInstruction.java │ ├── HVMInstructionSet.java │ └── VirtualMachine.java ├── HackGUIPackage ├── pom.xml └── src │ └── main │ └── java │ └── HackGUI │ ├── AbsolutePointedMemorySegmentComponent.java │ ├── BreakpointChangedEvent.java │ ├── BreakpointChangedListener.java │ ├── BreakpointVariablesWindow.java │ ├── BreakpointWindow.java │ ├── BreakpointsChangedEvent.java │ ├── BreakpointsChangedListener.java │ ├── BusComponent.java │ ├── ControllerComponent.java │ ├── ControllerFileChooser.java │ ├── EnterPressedListener.java │ ├── FileChooserComponent.java │ ├── FileChooserWindow.java │ ├── FileContentWindow.java │ ├── FileDisplayComponent.java │ ├── FilesTypeEvent.java │ ├── FilesTypeListener.java │ ├── Format.java │ ├── HTMLViewFrame.java │ ├── LabeledMemoryComponent.java │ ├── MemoryChangeListener.java │ ├── MemoryComponent.java │ ├── MemorySegmentComponent.java │ ├── MouseOverJButton.java │ ├── PointedMemoryComponent.java │ ├── PointedMemorySegmentComponent.java │ ├── ProfilerWindow.java │ ├── RegisterComponent.java │ ├── RepaintListener.java │ ├── ScriptFileFilter.java │ ├── SearchMemoryWindow.java │ ├── TextFileComponent.java │ ├── TextFileFilter.java │ ├── TitledComboBox.java │ ├── TranslationException.java │ ├── TrimmedValuesOnlyAbsoluteMemorySegmentComponent.java │ ├── Utilities.java │ ├── ValuesOnlyPointedMemoryComponent.java │ ├── ViewableFileChooserComponent.java │ └── WideTable.java ├── HackPackage ├── pom.xml └── src │ └── main │ └── java │ └── Hack │ ├── ComputerParts │ ├── AbsolutePointedMemorySegment.java │ ├── Bus.java │ ├── BusGUI.java │ ├── ComputerPart.java │ ├── ComputerPartErrorEvent.java │ ├── ComputerPartErrorEventListener.java │ ├── ComputerPartEvent.java │ ├── ComputerPartEventListener.java │ ├── ComputerPartGUI.java │ ├── InteractiveComputerPart.java │ ├── InteractiveComputerPartGUI.java │ ├── InteractiveValueComputerPart.java │ ├── InteractiveValueComputerPartGUI.java │ ├── LabeledPointedMemoryGUI.java │ ├── Memory.java │ ├── MemoryGUI.java │ ├── MemorySegment.java │ ├── MemorySegmentGUI.java │ ├── PointedMemory.java │ ├── PointedMemoryGUI.java │ ├── PointedMemorySegment.java │ ├── PointedMemorySegmentGUI.java │ ├── Register.java │ ├── RegisterGUI.java │ ├── TextFileEvent.java │ ├── TextFileEventListener.java │ ├── TextFileGUI.java │ ├── TrimmedAbsoluteMemorySegment.java │ ├── ValueComputerPart.java │ └── ValueComputerPartGUI.java │ ├── Controller │ ├── Breakpoint.java │ ├── Command.java │ ├── CommandException.java │ ├── ControllerEvent.java │ ├── ControllerEventListener.java │ ├── ControllerException.java │ ├── ControllerGUI.java │ ├── HackApplication.java │ ├── HackController.java │ ├── HackSimulator.java │ ├── HackSimulatorGUI.java │ ├── Profiler.java │ ├── ProgramException.java │ ├── Script.java │ ├── ScriptCondition.java │ ├── ScriptException.java │ ├── ScriptTokenizer.java │ ├── VariableException.java │ └── VariableFormat.java │ ├── Events │ ├── ClearEvent.java │ ├── ClearEventListener.java │ ├── ErrorEvent.java │ ├── ErrorEventListener.java │ ├── ProgramEvent.java │ └── ProgramEventListener.java │ ├── Translators │ ├── HackTranslator.java │ ├── HackTranslatorEvent.java │ ├── HackTranslatorEventListener.java │ ├── HackTranslatorException.java │ ├── HackTranslatorGUI.java │ └── LineTokenizer.java │ └── Utilities │ ├── Conversions.java │ ├── Definitions.java │ ├── GitRepositoryState.java │ ├── Graph.java │ ├── HackFileFilter.java │ └── Shifter.java ├── HardwareSimulator ├── pom.xml └── src │ └── main │ ├── java │ └── HardwareSimulatorMain.java │ └── resources │ ├── about.html │ ├── git.properties │ └── usage.html ├── InstallDir ├── .hack ├── CPUEmulator.bat ├── CPUEmulator.sh ├── HardwareSimulator.bat ├── HardwareSimulator.sh ├── OS │ ├── Array.vm │ ├── Keyboard.vm │ ├── Math.vm │ ├── Memory.vm │ ├── Output.vm │ ├── Screen.vm │ ├── String.vm │ └── Sys.vm ├── Readme.txt ├── TextComparer.bat ├── VMEmulator.bat ├── VMEmulator.sh ├── bin │ ├── help │ │ └── compiler.txt │ ├── images │ │ ├── arrow2.gif │ │ ├── calculator2.gif │ │ ├── cancel.gif │ │ ├── chip.gif │ │ ├── clock2.gif │ │ ├── equal.gif │ │ ├── find.gif │ │ ├── hex.gif │ │ ├── keyboard.gif │ │ ├── ok.gif │ │ ├── ok2.gif │ │ ├── open.gif │ │ ├── open2.gif │ │ ├── opendoc.gif │ │ ├── redflag.gif │ │ ├── save.gif │ │ ├── scroll.gif │ │ ├── smallcancel.gif │ │ ├── smallequal.gif │ │ ├── smallminus.gif │ │ ├── smallnew.gif │ │ ├── smallok.gif │ │ ├── smallplus.gif │ │ ├── vcrfastforward.gif │ │ ├── vcrforward.gif │ │ ├── vcrrewind.gif │ │ ├── vcrstepover.gif │ │ └── vcrstop.gif │ └── scripts │ │ ├── defaultCPU.txt │ │ ├── defaultHW.txt │ │ └── defaultVM.txt └── builtInChips │ ├── ALU.hdl │ ├── ARegister.hdl │ ├── Add16.hdl │ ├── And.hdl │ ├── And16.hdl │ ├── Bit.hdl │ ├── DFF.hdl │ ├── DMux.hdl │ ├── DMux4Way.hdl │ ├── DMux8Way.hdl │ ├── DRegister.hdl │ ├── FullAdder.hdl │ ├── HalfAdder.hdl │ ├── Inc16.hdl │ ├── Keyboard.hdl │ ├── Mux.hdl │ ├── Mux16.hdl │ ├── Mux4Way16.hdl │ ├── Mux8Way16.hdl │ ├── Nand.hdl │ ├── Not.hdl │ ├── Not16.hdl │ ├── Or.hdl │ ├── Or16.hdl │ ├── Or8Way.hdl │ ├── PC.hdl │ ├── RAM16K.hdl │ ├── RAM4K.hdl │ ├── RAM512.hdl │ ├── RAM64.hdl │ ├── RAM8.hdl │ ├── ROM32K.hdl │ ├── Register.hdl │ ├── Screen.hdl │ └── Xor.hdl ├── LICENSE ├── Readme.md ├── SimulatorsGUIPackage ├── pom.xml └── src │ └── main │ └── java │ └── SimulatorsGUI │ ├── ALUComponent.java │ ├── BinaryComponent.java │ ├── CPUEmulatorComponent.java │ ├── CallStackComponent.java │ ├── ChipLoaderFileChooser.java │ ├── GateInfoComponent.java │ ├── GatesPanel.java │ ├── HDLFileFilter.java │ ├── HackSimulatorComponent.java │ ├── HardwareSimulatorComponent.java │ ├── HardwareSimulatorControllerComponent.java │ ├── KeyboardComponent.java │ ├── MemorySegmentsComponent.java │ ├── PartPinsComponent.java │ ├── PartsComponent.java │ ├── PinValueEvent.java │ ├── PinValueListener.java │ ├── PinsComponent.java │ ├── ProgramComponent.java │ ├── ROMComponent.java │ ├── ROMFileFilter.java │ ├── ScreenComponent.java │ ├── SearchProgramWindow.java │ ├── StackCalculator.java │ ├── VMEmulatorComponent.java │ └── VMFileFilter.java ├── SimulatorsPackage ├── pom.xml └── src │ └── main │ └── java │ └── Hack │ ├── CPUEmulator │ ├── ALU.java │ ├── ALUGUI.java │ ├── CPU.java │ ├── CPUEmulator.java │ ├── CPUEmulatorApplication.java │ ├── CPUEmulatorGUI.java │ ├── Keyboard.java │ ├── KeyboardGUI.java │ ├── PointerAddressRegisterAdapter.java │ ├── RAM.java │ ├── ROM.java │ ├── ROMGUI.java │ └── ScreenGUI.java │ ├── Gates │ ├── BuiltInGate.java │ ├── BuiltInGateClass.java │ ├── BuiltInGateWithGUI.java │ ├── CompositeGate.java │ ├── CompositeGateClass.java │ ├── Connection.java │ ├── ConnectionSet.java │ ├── DirtyGateAdapter.java │ ├── DirtyGateListener.java │ ├── Gate.java │ ├── GateClass.java │ ├── GateClassSet.java │ ├── GateClassUnderLoad.java │ ├── GateErrorEvent.java │ ├── GateErrorEventListener.java │ ├── GateException.java │ ├── GatesManager.java │ ├── GatesPanelGUI.java │ ├── HDLException.java │ ├── HDLTokenizer.java │ ├── Node.java │ ├── NodeSet.java │ ├── PinInfo.java │ ├── SubBusListeningAdapter.java │ └── SubNode.java │ ├── HardwareSimulator │ ├── GateInfoGUI.java │ ├── HDLLineTokenizer.java │ ├── HardwareSimulator.java │ ├── HardwareSimulatorApplication.java │ ├── HardwareSimulatorController.java │ ├── HardwareSimulatorControllerEvent.java │ ├── HardwareSimulatorControllerGUI.java │ ├── HardwareSimulatorGUI.java │ ├── NodePartPinsAdapter.java │ ├── NodePinsAdapter.java │ ├── PartPinInfo.java │ ├── PartPins.java │ ├── PartPinsGUI.java │ ├── Parts.java │ ├── PartsGUI.java │ ├── Pins.java │ ├── PinsGUI.java │ └── SubNodePartPinsAdapter.java │ └── VMEmulator │ ├── BuiltInFunctionsRunner.java │ ├── BuiltInVMClass.java │ ├── CPU.java │ ├── Calculator.java │ ├── CalculatorGUI.java │ ├── CallStack.java │ ├── CallStackGUI.java │ ├── TerminateVMProgramThrowable.java │ ├── VMEmulator.java │ ├── VMEmulatorApplication.java │ ├── VMEmulatorGUI.java │ ├── VMEmulatorInstruction.java │ ├── VMProfiler.java │ ├── VMProgram.java │ ├── VMProgramGUI.java │ ├── VMProgramRowSelectionEvent.java │ └── VMProgramRowSelectionEventListener.java ├── TextComparer ├── pom.xml └── src │ └── main │ └── java │ └── TextComparer.java ├── VMEmulator ├── pom.xml └── src │ └── main │ ├── java │ └── VMEmulatorMain.java │ └── resources │ ├── about.html │ ├── git.properties │ └── usage.html ├── n2t-software-suite ├── Assembler.bat ├── Assembler.sh ├── CPUEmulator.bat ├── CPUEmulator.sh ├── HardwareSimulator.bat ├── HardwareSimulator.sh ├── JackCompiler.bat ├── JackCompiler.sh ├── Linux-CPUEmulator.desktop ├── Linux-HadrwareSimulator.desktop ├── Linux-VMEmulator.desktop ├── OS │ ├── Array.vm │ ├── Keyboard.vm │ ├── Math.vm │ ├── Memory.vm │ ├── Output.vm │ ├── Screen.vm │ ├── String.vm │ └── Sys.vm ├── TextComparer.bat ├── TextComparer.sh ├── VMEmulator.bat ├── VMEmulator.sh ├── bin │ ├── classes │ │ ├── CPUEmulatorMain.class │ │ ├── HackAssemblerMain.class │ │ ├── HardwareSimulatorMain.class │ │ ├── TextComparer.class │ │ └── VMEmulatorMain.class │ ├── help │ │ ├── asmAbout.html │ │ ├── asmUsage.html │ │ ├── compiler.txt │ │ ├── cpuAbout.html │ │ ├── cpuUsage.html │ │ ├── hwAbout.html │ │ ├── hwUsage.html │ │ ├── vmAbout.html │ │ └── vmUsage.html │ ├── images │ │ ├── arrow2.gif │ │ ├── calculator2.gif │ │ ├── cancel.gif │ │ ├── chip.gif │ │ ├── clock2.gif │ │ ├── equal.gif │ │ ├── find.gif │ │ ├── hex.gif │ │ ├── keyboard.gif │ │ ├── ok.gif │ │ ├── ok2.gif │ │ ├── open.gif │ │ ├── open2.gif │ │ ├── opendoc.gif │ │ ├── redflag.gif │ │ ├── save.gif │ │ ├── scroll.gif │ │ ├── smallcancel.gif │ │ ├── smallequal.gif │ │ ├── smallminus.gif │ │ ├── smallnew.gif │ │ ├── smallok.gif │ │ ├── smallplus.gif │ │ ├── vcrfastforward.gif │ │ ├── vcrforward.gif │ │ ├── vcrrewind.gif │ │ ├── vcrstepover.gif │ │ └── vcrstop.gif │ ├── lib │ │ ├── AssemblerGUI.jar │ │ ├── Compilers.jar │ │ ├── Hack.jar │ │ ├── HackGUI.jar │ │ ├── Simulators.jar │ │ ├── SimulatorsGUI.jar │ │ └── TranslatorsGUI.jar │ └── scripts │ │ ├── defaultCPU.txt │ │ ├── defaultHW.txt │ │ └── defaultVM.txt ├── builtInChips │ ├── ALU.class │ ├── ALU.hdl │ ├── ARegister.class │ ├── ARegister.hdl │ ├── Add16.class │ ├── Add16.hdl │ ├── And.class │ ├── And.hdl │ ├── And16.hdl │ ├── Bit.class │ ├── Bit.hdl │ ├── DFF.class │ ├── DFF.hdl │ ├── DMux.class │ ├── DMux.hdl │ ├── DMux4Way.class │ ├── DMux4Way.hdl │ ├── DMux8Way.class │ ├── DMux8Way.hdl │ ├── DRegister.class │ ├── DRegister.hdl │ ├── FullAdder.class │ ├── FullAdder.hdl │ ├── HalfAdder.class │ ├── HalfAdder.hdl │ ├── Inc16.class │ ├── Inc16.hdl │ ├── Keyboard.class │ ├── Keyboard.hdl │ ├── Mux.class │ ├── Mux.hdl │ ├── Mux16.hdl │ ├── Mux4Way16.class │ ├── Mux4Way16.hdl │ ├── Mux8Way16.class │ ├── Mux8Way16.hdl │ ├── Nand.class │ ├── Nand.hdl │ ├── Not.class │ ├── Not.hdl │ ├── Not16.class │ ├── Not16.hdl │ ├── Or.class │ ├── Or.hdl │ ├── Or16.hdl │ ├── Or8Way.class │ ├── Or8Way.hdl │ ├── PC.class │ ├── PC.hdl │ ├── RAM.class │ ├── RAM16K.class │ ├── RAM16K.hdl │ ├── RAM4K.class │ ├── RAM4K.hdl │ ├── RAM512.class │ ├── RAM512.hdl │ ├── RAM64.class │ ├── RAM64.hdl │ ├── RAM8.class │ ├── RAM8.hdl │ ├── ROM32K.class │ ├── ROM32K.hdl │ ├── Register.class │ ├── Register.hdl │ ├── RegisterWithGUI.class │ ├── Screen.class │ ├── Screen.hdl │ ├── Xor.class │ └── Xor.hdl └── builtInVMCode │ ├── Array.class │ ├── JackOSClass.class │ ├── Keyboard.class │ ├── Math.class │ ├── Memory.class │ ├── Output.class │ ├── Screen.class │ ├── String.class │ └── Sys.class ├── pom.xml └── prepare-release.sh /.gitignore: -------------------------------------------------------------------------------- 1 | */target 2 | target 3 | */dependency-reduced-pom.xml 4 | .idea 5 | **/*.iml 6 | Release/ 7 | -------------------------------------------------------------------------------- /BuiltInChips/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | BuiltInChips 12 | jar 13 | 14 | Built-in chips 15 | http://nand2tetris.org 16 | 17 | 18 | 19 | org.nand2tetris 20 | SimulatorsGUIPackage 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/ARegister.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * 16 bit address register. 22 | * If load[t]=1 then out[t+1] = in[t] 23 | * else out does not change 24 | */ 25 | public class ARegister extends RegisterWithGUI { 26 | 27 | /** 28 | * Constructs a new ARegister. 29 | */ 30 | public ARegister() { 31 | if (gui != null) { 32 | gui.setName("A:"); 33 | gui.setLocation(4,442); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Add16.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * A 16 bit integer adder. out is the sum of the two integers a and b. 24 | */ 25 | public class Add16 extends BuiltInGate { 26 | 27 | protected void reCompute() { 28 | short a = inputPins[0].get(); 29 | short b = inputPins[1].get(); 30 | outputPins[0].set((short)(a + b)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/And.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * A bitwise 1-bit And gate. 24 | */ 25 | public class And extends BuiltInGate { 26 | 27 | protected void reCompute() { 28 | short a = inputPins[0].get(); 29 | short b = inputPins[1].get(); 30 | outputPins[0].set((short)(a & b)); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Bit.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * 1 bit memory register. 24 | * If load[t]=1 then out[t+1] = in[t] else out does not change 25 | */ 26 | public class Bit extends BuiltInGate { 27 | 28 | // The state (0/1) of the bit. 29 | private short state; 30 | 31 | protected void clockUp() { 32 | short load = inputPins[1].get(); 33 | if (load == 1) 34 | state = inputPins[0].get(); 35 | } 36 | 37 | protected void clockDown() { 38 | outputPins[0].set(state); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/DFF.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.*; 21 | 22 | /** 23 | * The DFF chip. 24 | */ 25 | public class DFF extends BuiltInGate { 26 | 27 | // The state (0/1) of the DFF. 28 | private short state; 29 | 30 | protected void clockUp() { 31 | state = inputPins[0].get(); 32 | } 33 | 34 | protected void clockDown() { 35 | outputPins[0].set(state); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/DMux.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * 1 bit demultiplexer. 24 | * if sel=0 {a=in; b=0} else {a=0; b=in} 25 | */ 26 | public class DMux extends BuiltInGate { 27 | 28 | protected void reCompute() { 29 | short in = inputPins[0].get(); 30 | short sel = inputPins[1].get(); 31 | outputPins[0].set((short)(sel == 0 ? in : 0)); 32 | outputPins[1].set((short)(sel == 0 ? 0 : in)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/DRegister.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * A 16 bit data register. 22 | * If load[t]=1 then out[t+1] = in[t] 23 | * else out does not change 24 | */ 25 | public class DRegister extends RegisterWithGUI { 26 | 27 | /** 28 | * Constructs a new DRegister. 29 | */ 30 | public DRegister() { 31 | if (gui != null) { 32 | gui.setName("D:"); 33 | gui.setLocation(180,442); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/HalfAdder.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * A HalfAdder. 24 | * s returns the LSB of the sum of the two bits a and b. 25 | * c returns the carry bit. 26 | */ 27 | public class HalfAdder extends BuiltInGate { 28 | 29 | protected void reCompute() { 30 | short a = inputPins[0].get(); 31 | short b = inputPins[1].get(); 32 | outputPins[0].set((short)(a ^ b)); 33 | outputPins[1].set((short)(a & b)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Inc16.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * Adds the constant 1 to the input. 24 | */ 25 | public class Inc16 extends BuiltInGate { 26 | 27 | protected void reCompute() { 28 | short in = inputPins[0].get(); 29 | outputPins[0].set((short)(in + 1)); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Mux.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * 1-bit 2-way multiplexor. 24 | * if sel=1 out=b else out=a. 25 | */ 26 | public class Mux extends BuiltInGate { 27 | 28 | protected void reCompute() { 29 | short a = inputPins[0].get(); 30 | short b = inputPins[1].get(); 31 | short sel = inputPins[2].get(); 32 | outputPins[0].set((short)(sel == 0 ? a : b)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Nand.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.*; 21 | 22 | /** 23 | * A bitwise 1-bit Nand gate. 24 | */ 25 | public class Nand extends BuiltInGate { 26 | 27 | protected void reCompute() { 28 | short a = inputPins[0].get(); 29 | short b = inputPins[1].get(); 30 | outputPins[0].set((short)(0x1 - (a & b))); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Not.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * A bitwise 1-bit Not gate. 24 | */ 25 | public class Not extends BuiltInGate { 26 | 27 | protected void reCompute() { 28 | short in = inputPins[0].get(); 29 | outputPins[0].set((short)(1 - in)); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Not16.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * A bitwise 16-bit NOT gate. 22 | */ 23 | public class Not16 extends Not { 24 | 25 | protected void reCompute() { 26 | short in = inputPins[0].get(); 27 | outputPins[0].set((short)(~in)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Or.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * A bitwise 1-bit Or gate. 24 | */ 25 | public class Or extends BuiltInGate { 26 | 27 | protected void reCompute() { 28 | short a = inputPins[0].get(); 29 | short b = inputPins[1].get(); 30 | outputPins[0].set((short)(a | b)); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Or8Way.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * Or of 8 inputs into 1 output. 24 | * out=1 if one or more of the inputs is 1 and 0 otherwise. 25 | */ 26 | public class Or8Way extends BuiltInGate { 27 | 28 | protected void reCompute() { 29 | short in = inputPins[0].get(); 30 | outputPins[0].set((short)(in == 0 ? 0 : 1)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/RAM16K.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * RAM of 16K registers. 22 | */ 23 | public class RAM16K extends RAM { 24 | 25 | /** 26 | * Constructs a new RAM16K. 27 | */ 28 | public RAM16K() { 29 | super(16384); 30 | 31 | if (memoryGUI != null) { 32 | memoryGUI.setName("RAM 16K:"); 33 | memoryGUI.setVisibleRows(7); 34 | memoryGUI.setLocation(4,295); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/RAM4K.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * RAM of 4K registers. 22 | */ 23 | public class RAM4K extends RAM { 24 | 25 | /** 26 | * Constructs a new RAM4K. 27 | */ 28 | public RAM4K() { 29 | super(4096); 30 | if (memoryGUI != null) 31 | memoryGUI.setName("RAM 4K:"); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/RAM512.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * RAM of 512 registers. 22 | */ 23 | public class RAM512 extends RAM { 24 | 25 | public RAM512() { 26 | super(512); 27 | if (memoryGUI != null) 28 | memoryGUI.setName("RAM 512:"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/RAM64.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * RAM of 64 registers. 22 | */ 23 | public class RAM64 extends RAM { 24 | 25 | public RAM64() { 26 | super(64); 27 | if (memoryGUI != null) 28 | memoryGUI.setName("RAM 64:"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/RAM8.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | /** 21 | * RAM of 8 registers. 22 | */ 23 | public class RAM8 extends RAM { 24 | 25 | public RAM8() { 26 | super(8); 27 | if (memoryGUI != null) 28 | memoryGUI.setName("RAM 8:"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Register.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.*; 21 | 22 | /** 23 | * Represents a 16-bit register. 24 | */ 25 | public class Register extends BuiltInGate { 26 | 27 | // The 16 bit value 28 | protected short value; 29 | 30 | protected void clockUp() { 31 | short in = inputPins[0].get(); // 16 bit input 32 | short load = inputPins[1].get(); // load bit 33 | if (load == 1) 34 | value = in; 35 | } 36 | 37 | protected void clockDown() { 38 | outputPins[0].set(value); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /BuiltInChips/src/main/java/builtInChips/Xor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package builtInChips; 19 | 20 | import Hack.Gates.BuiltInGate; 21 | 22 | /** 23 | * A bitwise 1-bit Xor gate. 24 | */ 25 | public class Xor extends BuiltInGate { 26 | 27 | protected void reCompute() { 28 | short a = inputPins[0].get(); 29 | short b = inputPins[1].get(); 30 | outputPins[0].set((short)(a ^ b)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /BuiltInVMCode/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | BuiltInVMCode 12 | jar 13 | 14 | Built-in VM code 15 | http://nand2tetris.org 16 | 17 | 18 | 19 | org.nand2tetris 20 | SimulatorsPackage 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /CPUEmulator/src/main/resources/git.properties: -------------------------------------------------------------------------------- 1 | #Default properties, when building without git info 2 | git.dirty=true 3 | git.commit.id.describe-short=unknown 4 | git.build.version=${project.version} 5 | -------------------------------------------------------------------------------- /CompilersPackage/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | CompilersPackage 12 | jar 13 | 14 | Compilers package 15 | http://nand2tetris.org 16 | 17 | 18 | 19 | org.nand2tetris 20 | HackPackage 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /HackGUIPackage/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | HackGUIPackage 12 | jar 13 | 14 | Hack GUI package 15 | http://nand2tetris.org 16 | 17 | 18 | 19 | org.nand2tetris 20 | HackPackage 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /HackGUIPackage/src/main/java/HackGUI/BreakpointChangedListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package HackGUI; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the BreakpointChangedEvent. 22 | */ 23 | public interface BreakpointChangedListener { 24 | 25 | /** 26 | * Called when there was a change in one of the breakpoints. 27 | * The event contains the changed breakpoint. 28 | */ 29 | public void breakpointChanged(BreakpointChangedEvent event); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /HackGUIPackage/src/main/java/HackGUI/BreakpointsChangedListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package HackGUI; 19 | 20 | /** 21 | * An interface for objects that want to listen to the BreakpointChangedEvent. 22 | */ 23 | public interface BreakpointsChangedListener { 24 | 25 | /** 26 | * Called when there was a change in the breakpoints vector. 27 | * The event contains the vector of breakpoints. 28 | */ 29 | public void breakpointsChanged(BreakpointsChangedEvent event); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /HackGUIPackage/src/main/java/HackGUI/EnterPressedListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package HackGUI; 19 | 20 | /** 21 | * An interface for objects that wants to listen to events of pressing the enter 22 | * button. 23 | */ 24 | public interface EnterPressedListener { 25 | 26 | /** 27 | * called when the enter button was pressed by the user. 28 | */ 29 | public void enterPressed(); 30 | } 31 | -------------------------------------------------------------------------------- /HackGUIPackage/src/main/java/HackGUI/FilesTypeListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package HackGUI; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the FilesTypeEvent. 22 | */ 23 | public interface FilesTypeListener { 24 | 25 | /** 26 | * Called when the names of the files were changed. 27 | * The event contains the three strings representing the names of the 28 | * files. 29 | */ 30 | public void filesNamesChanged(FilesTypeEvent event); 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /HackGUIPackage/src/main/java/HackGUI/MemoryChangeListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package HackGUI; 19 | 20 | /** 21 | * An interface for objects that wants to listen to Memory changes. 22 | */ 23 | public interface MemoryChangeListener { 24 | 25 | /** 26 | * Called when the a change occured in the memory that requires repaint. 27 | */ 28 | public void repaintChange(); 29 | 30 | /** 31 | * Called when the a change occured in the memory that requires revalidate. 32 | */ 33 | public void revalidateChange(); 34 | } 35 | -------------------------------------------------------------------------------- /HackGUIPackage/src/main/java/HackGUI/RepaintListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package HackGUI; 19 | 20 | /** 21 | * An interface for objects that wants to listen to other object that calls to its 22 | * repaint() method. 23 | */ 24 | public interface RepaintListener { 25 | 26 | /** 27 | * Called when the object calles to its repaint() method. 28 | * There is no event in this case. 29 | */ 30 | public void repaintSegments(); 31 | } 32 | -------------------------------------------------------------------------------- /HackGUIPackage/src/main/java/HackGUI/TranslationException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package HackGUI; 19 | 20 | /** 21 | * An exception for translation errors. 22 | */ 23 | public class TranslationException extends Exception 24 | { 25 | /** 26 | * Constructs a new TranslationException with the given message. 27 | */ 28 | public TranslationException(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | HackPackage 12 | jar 13 | 14 | Hack package 15 | http://nand2tetris.org 16 | 17 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/ComputerPartErrorEvent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | import Hack.Events.*; 21 | 22 | /** 23 | * An event for notifying a ComputerPartErrorEventListener on an error that occured 24 | * in a computer part. 25 | */ 26 | public class ComputerPartErrorEvent extends ErrorEvent { 27 | 28 | /** 29 | * Constructs a new ComputerPartErrorEvent with the given source (computer part) 30 | * and errorMessage. 31 | */ 32 | public ComputerPartErrorEvent(ComputerPart source, String errorMessage) { 33 | super(source, errorMessage); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/ComputerPartErrorEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | /** 21 | * An interface for objects that want to listen to the ComputerPartErrorEvent. 22 | */ 23 | public interface ComputerPartErrorEventListener { 24 | 25 | /** 26 | * Called when an error occured in the ComputerPart. 27 | * The event contains the source object and the error message. 28 | */ 29 | public void computerPartErrorOccured(ComputerPartErrorEvent event); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/ComputerPartEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the ComputerPartEvent. 22 | */ 23 | public interface ComputerPartEventListener { 24 | 25 | /** 26 | * Called when the contents of the ComputerPart are changed. 27 | * The event contains the source object, the changed index and the new value. 28 | */ 29 | public void valueChanged(ComputerPartEvent event); 30 | 31 | /** 32 | * Called when the ComputerPart's GUI gained focus. 33 | */ 34 | public void guiGainedFocus(); 35 | } 36 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/ComputerPartGUI.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | /** 21 | * An interface for the GUI of a Computer Part. 22 | */ 23 | public interface ComputerPartGUI { 24 | 25 | /** 26 | * Resets the contents of the computer part GUI. 27 | */ 28 | public void reset(); 29 | } 30 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/PointedMemoryGUI.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | /** 21 | * An interface for a pointed memory GUI. 22 | * This memory gui has a pointer (address) which should be marked. 23 | */ 24 | public interface PointedMemoryGUI extends MemoryGUI { 25 | 26 | /** 27 | * Sets the pointer with the given pointer address. 28 | */ 29 | public void setPointer(int pointerAddress); 30 | } 31 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/PointedMemorySegmentGUI.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | /** 21 | * An interface for a pointed memory segment GUI. 22 | * This memory segment gui has a pointer (address) which should be marked. 23 | */ 24 | public interface PointedMemorySegmentGUI extends MemorySegmentGUI { 25 | 26 | /** 27 | * Sets the pointer with the given pointer address (absolute address). 28 | */ 29 | public void setPointer(int pointerAddress); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/RegisterGUI.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | /** 21 | * An interface for a computer register GUI. Has a 16-bit numeric value. 22 | */ 23 | public interface RegisterGUI extends InteractiveValueComputerPartGUI { 24 | } 25 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/ComputerParts/TextFileEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.ComputerParts; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the TextFileEvent. 22 | */ 23 | public interface TextFileEventListener { 24 | 25 | /** 26 | * Called when a new row is selected in a Text File. 27 | * The event contains the source object and the selected row String. 28 | */ 29 | public void rowSelected(TextFileEvent event); 30 | } 31 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Controller/ControllerEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Controller; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the ControllerEvent. 22 | */ 23 | public interface ControllerEventListener { 24 | 25 | /** 26 | * Called when an action should be taken in the controller. 27 | * The given event contains the source object, the performed action's code 28 | * and the action's supplied data object. 29 | */ 30 | public void actionPerformed(ControllerEvent event); 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Controller/ControllerException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Controller; 19 | 20 | /** 21 | * An exception for errors in the controller operation. 22 | */ 23 | public class ControllerException extends Exception 24 | { 25 | /** 26 | * Constructs a new ControllerException with the given message. 27 | */ 28 | public ControllerException(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Controller/Profiler.java: -------------------------------------------------------------------------------- 1 | package Hack.Controller; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.atomic.AtomicInteger; 5 | 6 | public interface Profiler { 7 | 8 | void reset(); 9 | 10 | String[] getTabNames(); 11 | 12 | String[] getTableHeaders(int tab); 13 | 14 | Map getData(int tab); 15 | 16 | boolean isEnabled(); 17 | 18 | void setEnabled(boolean enabled); 19 | } 20 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Controller/VariableException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Controller; 19 | 20 | /** 21 | * An exception for errors with variable definitions. 22 | */ 23 | public class VariableException extends Exception 24 | { 25 | /** 26 | * Constructs a new VariableException with the given message and variable name. 27 | */ 28 | public VariableException(String message, String varName) { 29 | super(message + ": " + varName); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Events/ClearEvent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Events; 19 | 20 | import java.util.EventObject; 21 | 22 | /** 23 | * An event for notifying a ClearEventListener on a request for clear. 24 | */ 25 | public class ClearEvent extends EventObject { 26 | 27 | /** 28 | * Constructs a new ClearEvent with the given source. 29 | */ 30 | public ClearEvent(Object source) { 31 | super(source); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Events/ClearEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Events; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the ClearEvent. 22 | */ 23 | public interface ClearEventListener { 24 | 25 | /** 26 | * Called when clear is requested. 27 | * The event contains the source object. 28 | */ 29 | public void clearRequested(ClearEvent event); 30 | } 31 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Events/ErrorEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Events; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the ErrorEvent. 22 | */ 23 | public interface ErrorEventListener { 24 | 25 | /** 26 | * Called when an error occured. 27 | * The event contains the source object and the error message. 28 | */ 29 | public void errorOccured(ErrorEvent event); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Events/ProgramEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Events; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the ProgramEvent. 22 | */ 23 | public interface ProgramEventListener { 24 | 25 | /** 26 | * Called when the current program is changed. 27 | * The event contains the source object, and the new program's file name. 28 | */ 29 | public void programChanged(ProgramEvent event); 30 | } 31 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Translators/HackTranslatorEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Translators; 19 | 20 | /** 21 | * An interface for objects that want to listen to HackTranslatorEvents. 22 | */ 23 | public interface HackTranslatorEventListener { 24 | 25 | /** 26 | * Called when an action was performed in the HackTranslatorGUI. 27 | * The given event contains the source object, the performed action's code 28 | * and the action's supplied data object. 29 | */ 30 | public void actionPerformed(HackTranslatorEvent event); 31 | } 32 | -------------------------------------------------------------------------------- /HackPackage/src/main/java/Hack/Utilities/GitRepositoryState.java: -------------------------------------------------------------------------------- 1 | package Hack.Utilities; 2 | 3 | import java.io.IOException; 4 | import java.io.InputStream; 5 | import java.net.URL; 6 | import java.util.Properties; 7 | 8 | class GitRepositoryState { 9 | private static GitRepositoryState gitRepositoryState; 10 | private final String describeShort; 11 | private final String buildVersion; 12 | 13 | static GitRepositoryState getGitRepositoryState() throws IOException { 14 | if (gitRepositoryState == null) { 15 | final URL gitProperties = GitRepositoryState.class.getClassLoader().getResource("git.properties"); 16 | final Properties properties = new Properties(); 17 | if (gitProperties != null) { 18 | try (InputStream is = gitProperties.openStream()) { 19 | properties.load(is); 20 | } 21 | } else { 22 | properties.setProperty("git.commit.id.describe-short", "unknown"); 23 | properties.setProperty("git.build.version", "unknown"); 24 | } 25 | 26 | gitRepositoryState = new GitRepositoryState(properties); 27 | } 28 | return gitRepositoryState; 29 | } 30 | 31 | private GitRepositoryState(Properties properties) { 32 | this.describeShort = String.valueOf(properties.get("git.commit.id.describe-short")); 33 | this.buildVersion = String.valueOf(properties.get("git.build.version")); 34 | } 35 | 36 | String getDescribeShort() { 37 | return describeShort; 38 | } 39 | 40 | String getBuildVersion() { 41 | return buildVersion; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /HardwareSimulator/src/main/resources/git.properties: -------------------------------------------------------------------------------- 1 | #Default properties, when building without git info 2 | git.dirty=true 3 | git.commit.id.describe-short=unknown 4 | git.build.version=${project.version} 5 | -------------------------------------------------------------------------------- /InstallDir/.hack: -------------------------------------------------------------------------------- 1 | 0000000000000000 2 | 1111110000010000 3 | 0000000000010111 4 | 1110001100000110 5 | 0000000000010000 6 | 1110001100001000 7 | 0100000000000000 8 | 1110110000010000 9 | 0000000000010001 10 | 1110001100001000 11 | 0000000000010001 12 | 1111110000100000 13 | 1110111010001000 14 | 0000000000010001 15 | 1111110000010000 16 | 0000000000100000 17 | 1110000010010000 18 | 0000000000010001 19 | 1110001100001000 20 | 0000000000010000 21 | 1111110010011000 22 | 0000000000001010 23 | 1110001100000001 24 | 0000000000010111 25 | 1110101010000111 26 | -------------------------------------------------------------------------------- /InstallDir/CPUEmulator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %0\.. 3 | java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" CPUEmulatorMain %1 4 | -------------------------------------------------------------------------------- /InstallDir/CPUEmulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` 3 | java -jar ../CPUEmulator/target/CPUEmulator-*.jar $1 4 | -------------------------------------------------------------------------------- /InstallDir/HardwareSimulator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %0\.. 3 | java -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" HardwareSimulatorMain %1 4 | -------------------------------------------------------------------------------- /InstallDir/HardwareSimulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | cd `dirname $0` 3 | java -jar ../HardwareSimulator/target/HardwareSimulator-*.jar $@ 4 | -------------------------------------------------------------------------------- /InstallDir/OS/Array.vm: -------------------------------------------------------------------------------- 1 | function Array.new 0 2 | push argument 0 3 | push constant 0 4 | gt 5 | not 6 | if-goto IF_TRUE0 7 | goto IF_FALSE0 8 | label IF_TRUE0 9 | push constant 2 10 | call Sys.error 1 11 | pop temp 0 12 | label IF_FALSE0 13 | push argument 0 14 | call Memory.alloc 1 15 | return 16 | function Array.dispose 0 17 | push argument 0 18 | pop pointer 0 19 | push pointer 0 20 | call Memory.deAlloc 1 21 | pop temp 0 22 | push constant 0 23 | return 24 | -------------------------------------------------------------------------------- /InstallDir/OS/Sys.vm: -------------------------------------------------------------------------------- 1 | function Sys.init 0 2 | call Memory.init 0 3 | pop temp 0 4 | call Math.init 0 5 | pop temp 0 6 | call Screen.init 0 7 | pop temp 0 8 | call Output.init 0 9 | pop temp 0 10 | call Keyboard.init 0 11 | pop temp 0 12 | call Main.main 0 13 | pop temp 0 14 | call Sys.halt 0 15 | pop temp 0 16 | push constant 0 17 | return 18 | function Sys.halt 0 19 | label WHILE_EXP0 20 | push constant 0 21 | not 22 | not 23 | if-goto WHILE_END0 24 | goto WHILE_EXP0 25 | label WHILE_END0 26 | push constant 0 27 | return 28 | function Sys.wait 1 29 | push argument 0 30 | push constant 0 31 | lt 32 | if-goto IF_TRUE0 33 | goto IF_FALSE0 34 | label IF_TRUE0 35 | push constant 1 36 | call Sys.error 1 37 | pop temp 0 38 | label IF_FALSE0 39 | label WHILE_EXP0 40 | push argument 0 41 | push constant 0 42 | gt 43 | not 44 | if-goto WHILE_END0 45 | push constant 50 46 | pop local 0 47 | label WHILE_EXP1 48 | push local 0 49 | push constant 0 50 | gt 51 | not 52 | if-goto WHILE_END1 53 | push local 0 54 | push constant 1 55 | sub 56 | pop local 0 57 | goto WHILE_EXP1 58 | label WHILE_END1 59 | push argument 0 60 | push constant 1 61 | sub 62 | pop argument 0 63 | goto WHILE_EXP0 64 | label WHILE_END0 65 | push constant 0 66 | return 67 | function Sys.error 0 68 | push constant 3 69 | call String.new 1 70 | push constant 69 71 | call String.appendChar 2 72 | push constant 82 73 | call String.appendChar 2 74 | push constant 82 75 | call String.appendChar 2 76 | call Output.printString 1 77 | pop temp 0 78 | push argument 0 79 | call Output.printInt 1 80 | pop temp 0 81 | call Sys.halt 0 82 | pop temp 0 83 | push constant 0 84 | return 85 | -------------------------------------------------------------------------------- /InstallDir/TextComparer.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %0\.. 3 | java -classpath "%CLASSPATH%;bin/classes" TextComparer %1 %2 4 | -------------------------------------------------------------------------------- /InstallDir/VMEmulator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd %0\.. 3 | java -classpath "%CLASSPATH%;.;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Simulators.jar;bin/lib/SimulatorsGUI.jar;bin/lib/Compilers.jar" VMEmulatorMain %1 4 | -------------------------------------------------------------------------------- /InstallDir/VMEmulator.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd $(dirname $0) 3 | if [[ $# -eq 0 ]]; then 4 | java -jar ../VMEmulator/target/VMEmulator-*.jar 5 | elif [[ $# -eq 1 ]]; then 6 | [ -z "$N2T_VM_USE_BUILTINS" ] && export N2T_VM_USE_BUILTINS="yes" 7 | java -jar ../VMEmulator/target/VMEmulator-*.jar "$1" 8 | else 9 | echo "The program expects 0 or 1 arguments!" 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /InstallDir/bin/help/compiler.txt: -------------------------------------------------------------------------------- 1 | 2 | Jack Compiler, Version 2.6 3 | 4 | This program is part of the software suite that accompanies the book: 5 | 6 | The Elements of Computing Systems 7 | by Noam Nisan and Shimon Schocken 8 | MIT Press, 2005 9 | Book site: www.idc.ac.il/tecs 10 | 11 | Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski 12 | 13 | Usage instruction and tips can be found in the relevant book chapters. 14 | -------------------------------------------------------------------------------- /InstallDir/bin/images/arrow2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/arrow2.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/calculator2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/calculator2.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/cancel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/cancel.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/chip.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/chip.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/clock2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/clock2.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/equal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/equal.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/find.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/find.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/hex.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/hex.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/keyboard.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/keyboard.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/ok.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/ok.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/ok2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/ok2.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/open.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/open2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/open2.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/opendoc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/opendoc.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/redflag.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/redflag.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/save.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/save.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/scroll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/scroll.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/smallcancel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/smallcancel.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/smallequal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/smallequal.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/smallminus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/smallminus.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/smallnew.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/smallnew.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/smallok.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/smallok.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/smallplus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/smallplus.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/vcrfastforward.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/vcrfastforward.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/vcrforward.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/vcrforward.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/vcrrewind.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/vcrrewind.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/vcrstepover.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/vcrstepover.gif -------------------------------------------------------------------------------- /InstallDir/bin/images/vcrstop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/InstallDir/bin/images/vcrstop.gif -------------------------------------------------------------------------------- /InstallDir/bin/scripts/defaultCPU.txt: -------------------------------------------------------------------------------- 1 | repeat { 2 | ticktock; 3 | } -------------------------------------------------------------------------------- /InstallDir/bin/scripts/defaultHW.txt: -------------------------------------------------------------------------------- 1 | repeat { 2 | tick, 3 | tock; 4 | } -------------------------------------------------------------------------------- /InstallDir/bin/scripts/defaultVM.txt: -------------------------------------------------------------------------------- 1 | repeat { 2 | vmstep; 3 | } -------------------------------------------------------------------------------- /InstallDir/builtInChips/ALU.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/ALU.hdl 5 | 6 | /** 7 | * The ALU. Computes a pre-defined set of functions out = f(x,y) 8 | * where x and y are two 16-bit inputs. The function f is selected 9 | * by a set of 6 control bits denoted zx, nx, zy, ny, f, no. 10 | * The ALU operation can be described using the following pseudocode: 11 | * if zx=1 set x = 0 // 16-bit zero constant 12 | * if nx=1 set x = !x // Bit-wise negation 13 | * if zy=1 set y = 0 // 16-bit zero constant 14 | * if ny=1 set y = !y // Bit-wise negation 15 | * if f=1 set out = x + y // Integer 2's complement addition 16 | * else set out = x & y // Bit-wise And 17 | * if no=1 set out = !out // Bit-wise negation 18 | * 19 | * In addition to computing out, the ALU computes two 1-bit outputs: 20 | * if out=0 set zr = 1 else zr = 0 // 16-bit equality comparison 21 | * if out<0 set ng = 1 else ng = 0 // 2's complement comparison 22 | */ 23 | 24 | CHIP ALU { 25 | 26 | IN // 16-bit inputs: 27 | x[16], y[16], 28 | // Control bits: 29 | zx, // Zero the x input 30 | nx, // Negate the x input 31 | zy, // Zero the y input 32 | ny, // Negate the y input 33 | f, // Function code: 1 for add, 0 for and 34 | no; // Negate the out output 35 | 36 | OUT // 16-bit output 37 | out[16], 38 | 39 | // ALU output flags 40 | zr, // 1 if out=0, 0 otherwise 41 | ng; // 1 if out<0, 0 otherwise 42 | 43 | BUILTIN ALU; 44 | } 45 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/ARegister.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/ARegister.hdl 5 | 6 | /** 7 | * A 16-Bit register called "A Register". 8 | * If load[t-1]=1 then out[t] = in[t-1] 9 | * else out does not change (out[t] = out[t-1]) 10 | * 11 | * This built-in chip implementation has the side effect of 12 | * providing a GUI representation of a 16-bit register 13 | * called "A register" (typically used to store an address). 14 | */ 15 | 16 | CHIP ARegister { 17 | 18 | IN in[16], load; 19 | OUT out[16]; 20 | 21 | BUILTIN ARegister; 22 | CLOCKED in, load; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Add16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Add16.hdl 5 | 6 | /** 7 | * 16-bit integer adder. out = a + b where a,b are 16-bit 8 | * 2's complement representations of integers. Overflow is 9 | * neither detected nor handled. 10 | */ 11 | 12 | CHIP Add16 { 13 | 14 | IN a[16], b[16]; 15 | OUT out[16]; 16 | 17 | BUILTIN Add16; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/And.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/And.hdl 5 | 6 | /** 7 | * And gate: out = a and b. 8 | */ 9 | 10 | CHIP And { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN And; 16 | } 17 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/And16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/And16.hdl 5 | 6 | /** 7 | * 16-bit and gate. For i=0..15 out[i] = a[i] and b[i] 8 | */ 9 | 10 | CHIP And16 { 11 | 12 | IN a[16], b[16]; 13 | OUT out[16]; 14 | 15 | BUILTIN And; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Bit.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Bit.hdl 5 | 6 | /** 7 | * 1-bit memory register. 8 | * If load[t-1]=1 then out[t] = in[t-1] 9 | * else out does not change (out[t] = out[t-1]) 10 | */ 11 | 12 | CHIP Bit { 13 | 14 | IN in, load; 15 | OUT out; 16 | 17 | BUILTIN Bit; 18 | CLOCKED in, load; 19 | } 20 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/DFF.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/DFF.hdl 5 | 6 | /** 7 | * Data Flip-flop: out(t)=in(t-1) 8 | * where t is the current time unit, or clock cycle. 9 | */ 10 | 11 | CHIP DFF { 12 | 13 | IN in; 14 | OUT out; 15 | 16 | BUILTIN DFF; 17 | CLOCKED in; 18 | } 19 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/DMux.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/DMux.hdl 5 | 6 | /** 7 | * Demultiplexer. If sel = 0 then {a = in; b = 0} else {a = 0; b = in} 8 | */ 9 | 10 | CHIP DMux { 11 | 12 | IN in, sel; 13 | OUT a, b; 14 | 15 | BUILTIN DMux; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/DMux4Way.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/DMux4Way.hdl 5 | 6 | /** 7 | * 4-way demultiplexor. The 2-bit sel input selects the output to which 8 | * the in input will be channeled: 00 to a, 01 to b, 10 to c, 11 to d. 9 | * The other outputs are set to 0. 10 | */ 11 | 12 | CHIP DMux4Way { 13 | 14 | IN in, sel[2]; 15 | OUT a, b, c, d; 16 | 17 | BUILTIN DMux4Way; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/DMux8Way.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/DMux8Way.hdl 5 | 6 | /** 7 | * 8-way demultiplexor. The 3-bit sel input selects the output to which 8 | * the in input will be channeled: (000 to a, 001 to b, ..., 111 to h). 9 | * The other outputs are set to 0. 10 | */ 11 | 12 | CHIP DMux8Way { 13 | 14 | IN in, sel[3]; 15 | OUT a, b, c, d, e, f, g, h; 16 | 17 | BUILTIN DMux8Way; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/DRegister.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/DRegister.hdl 5 | 6 | /** 7 | * A 16-Bit register called "D Register". 8 | * If load[t-1]=1 then out[t] = in[t-1] 9 | * else out does not change (out[t] = out[t-1]) 10 | * 11 | * This built-in chip implementation has the side effect of 12 | * providing a GUI representation of a 16-bit register 13 | * called "D register" (typically used to store data). 14 | */ 15 | 16 | CHIP DRegister { 17 | 18 | IN in[16], load; 19 | OUT out[16]; 20 | 21 | BUILTIN DRegister; 22 | CLOCKED in, load; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/FullAdder.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/FullAdder.hdl 5 | 6 | /** 7 | * Full adder. Computes sum, the least significant bit of 8 | * a + b + c, and carry, the most significant bit of a + b + c. 9 | */ 10 | 11 | CHIP FullAdder { 12 | 13 | IN a, b, c; 14 | OUT sum, // LSB of a + b + c 15 | carry; // MSB of a + b + c 16 | 17 | BUILTIN FullAdder; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/HalfAdder.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/HalfAdder.hdl 5 | 6 | /** 7 | * Half adder. Computes sum, the least significnat bit of a + b, 8 | * and carry, the most significnat bit of a + b. 9 | */ 10 | 11 | CHIP HalfAdder { 12 | 13 | IN a, b; 14 | OUT sum, // LSB of a + b 15 | carry; // MSB of a + b 16 | 17 | BUILTIN HalfAdder; 18 | } 19 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Inc16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Inc16.hdl 5 | 6 | /** 7 | * 16-bit incrementer. out = in + 1 (16-bit addition). 8 | * Overflow is neither detected nor handled. 9 | */ 10 | 11 | CHIP Inc16 { 12 | 13 | IN in[16]; 14 | OUT out[16]; 15 | 16 | BUILTIN Inc16; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Keyboard.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Keyboard.hdl 5 | 6 | /** 7 | * The keyboard (memory map). 8 | * Outputs the code of the currently pressed key. 9 | * 10 | * The built-in chip implementation has two side effects supplied 11 | * by the simulator. First, the keyboard memory map is continuously 12 | * being refreshed from the physical keyboard unit. Second, it 13 | * displays a keyboard icon and data entry GUI. 14 | */ 15 | 16 | CHIP Keyboard { 17 | 18 | OUT out[16]; // The ASCII code of the pressed key, 19 | // or 0 if no key is currently pressed, 20 | // or one the special codes listed in Figure 5.5. 21 | 22 | BUILTIN Keyboard; 23 | } 24 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Mux.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Mux.hdl 5 | 6 | /** 7 | * Multiplexor. If sel=0 then out = a else out = b. 8 | */ 9 | 10 | CHIP Mux { 11 | 12 | IN a, b, sel; 13 | OUT out; 14 | 15 | BUILTIN Mux; 16 | } 17 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Mux16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Mux16.hdl 5 | 6 | /** 7 | * 16-bit multiplexor. If sel=0 then out = a else out = b. 8 | */ 9 | 10 | CHIP Mux16 { 11 | 12 | IN a[16], b[16], sel; 13 | OUT out[16]; 14 | 15 | BUILTIN Mux; 16 | } 17 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Mux4Way16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Mux4Way16.hdl 5 | 6 | /** 7 | * 4-way 16-bit multiplexor. 8 | * out = a -- if sel=00 9 | * b -- if sel=01 10 | * c -- if sel=10 11 | * d -- if sel=11 12 | */ 13 | 14 | CHIP Mux4Way16 { 15 | 16 | IN a[16], b[16], c[16], d[16], sel[2]; 17 | OUT out[16]; 18 | 19 | BUILTIN Mux4Way16; 20 | } 21 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Mux8Way16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Mux8Way16.hdl 5 | 6 | /** 7 | * 8-way 16-bit multiplexor. 8 | * out = a -- if sel=000 9 | * b -- if sel=001 10 | * ... 11 | * h -- if sel=111 12 | */ 13 | 14 | CHIP Mux8Way16 { 15 | 16 | IN a[16], b[16], c[16], d[16], 17 | e[16], f[16], g[16], h[16], 18 | sel[3]; 19 | 20 | OUT out[16]; 21 | 22 | BUILTIN Mux8Way16; 23 | } -------------------------------------------------------------------------------- /InstallDir/builtInChips/Nand.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Nand.hdl 5 | 6 | /** 7 | * Nand gate: out = a nand b. 8 | */ 9 | 10 | CHIP Nand { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN Nand; 16 | } 17 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Not.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Not.hdl 5 | 6 | /** 7 | * Not gate. out = not in. 8 | */ 9 | 10 | CHIP Not { 11 | 12 | IN in; 13 | OUT out; 14 | 15 | BUILTIN Not; 16 | } -------------------------------------------------------------------------------- /InstallDir/builtInChips/Not16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Not16.hdl 5 | 6 | /** 7 | * 16-bit negation gate: for i=0..15 out[i] = not in[i] 8 | */ 9 | 10 | CHIP Not16 { 11 | 12 | IN in[16]; 13 | OUT out[16]; 14 | 15 | BUILTIN Not16; 16 | } -------------------------------------------------------------------------------- /InstallDir/builtInChips/Or.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Or.hdl 5 | 6 | /** 7 | * Or gate. out = a or b 8 | */ 9 | 10 | CHIP Or { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN Or; 16 | } 17 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Or16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Or16.hdl 5 | 6 | /** 7 | * 16-bit Or gate. For i=0..15 out[i] = a[i] or b[i] 8 | */ 9 | 10 | CHIP Or16 { 11 | 12 | IN a[16], b[16]; 13 | OUT out[16]; 14 | 15 | BUILTIN Or; 16 | } 17 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Or8Way.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Or8Way.hdl 5 | 6 | /** 7 | * 8-way Or gate. out = in[0] or in[1] or ... or in[7] 8 | */ 9 | 10 | CHIP Or8Way { 11 | 12 | IN in[8]; 13 | OUT out; 14 | 15 | BUILTIN Or8Way; 16 | } 17 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/PC.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/PC.hdl 5 | 6 | /** 7 | * 16-bit counter with load and reset controls. 8 | * 9 | * If reset(t-1) then out(t) = 0 10 | * else if load(t-1) then out(t) = in(t-1) 11 | * else if inc(t-1) then out(t) = out(t-1) + 1 (integer addition) 12 | * else out(t) = out(t-1) 13 | */ 14 | 15 | CHIP PC { 16 | 17 | IN in[16], load, inc, reset; 18 | OUT out[16]; 19 | 20 | BUILTIN PC; 21 | CLOCKED in, load, inc, reset; 22 | } 23 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/RAM16K.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/RAM16K.hdl 5 | 6 | /** 7 | * Memory of 16K registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM16K[address(t)](t) 10 | * Write: If load(t-1) then RAM16K[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load=1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | 18 | CHIP RAM16K { 19 | 20 | IN in[16], load, address[14]; 21 | OUT out[16]; 22 | 23 | BUILTIN RAM16K; 24 | CLOCKED in, load; 25 | } 26 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/RAM4K.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/RAM4K.hdl 5 | 6 | /** 7 | * Memory of 4K registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM4K[address(t)](t) 10 | * Write: If load(t-1) then RAM4K[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load=1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM4K { 18 | 19 | IN in[16], load, address[12]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM4K; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/RAM512.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/RAM512.hdl 5 | 6 | /** 7 | * Memory of 512 registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM512[address(t)](t) 10 | * Write: If load(t-1) then RAM512[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load=1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM512 { 18 | 19 | IN in[16], load, address[9]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM512; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/RAM64.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/RAM64.hdl 5 | 6 | /** 7 | * Memory of 64 registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM64[address(t)](t) 10 | * Write: If load(t-1) then RAM64[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load=1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM64 { 18 | 19 | IN in[16], load, address[6]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM64; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/RAM8.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/RAM8.hdl 5 | 6 | /** 7 | * Memory of 8 registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM8[address(t)](t) 10 | * Write: If load(t-1) then RAM8[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load=1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM8 { 18 | 19 | IN in[16], load, address[3]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM8; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/ROM32K.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/ROM32K.hdl 5 | 6 | /** 7 | * Read-Only memory (ROM) of 16K registers, each 16-bit wide. 8 | * The chip is designed to facilitate data read, as follows: 9 | * out(t) = ROM32K[address(t)](t) 10 | * In words: the chip always outputs the value stored at the 11 | * memory location specified by address. 12 | * 13 | * The built-in chip implementation has a GUI side-effect, 14 | * showing an array-like component that displays the ROM's 15 | * contents. The ROM32K chip is supposed to be pre-loaded with 16 | * a machine language program. To that end, the built-in chip 17 | * implementation also knows how to handle the "ROM32K load Xxx" 18 | * script command, where Xxx is the name of a text file containing 19 | * a program written in the Hack machine language. When the 20 | * simulator encounters such a command in a test script, the code 21 | * found in the file is loaded into the simulated ROM32K unit. 22 | */ 23 | 24 | CHIP ROM32K { 25 | 26 | IN address[15]; 27 | OUT out[16]; 28 | 29 | BUILTIN ROM32K; 30 | } 31 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Register.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Register.hdl 5 | 6 | /** 7 | * 16-Bit register. 8 | * If load[t-1]=1 then out[t] = in[t-1] 9 | * else out does not change (out[t] = out[t-1]) 10 | */ 11 | 12 | CHIP Register { 13 | 14 | IN in[16], load; 15 | OUT out[16]; 16 | 17 | BUILTIN Register; 18 | CLOCKED in, load; 19 | } 20 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Screen.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Screen.hdl 5 | 6 | /** 7 | * The Screen (memory map). 8 | * Functions exactly like a 16-bit 8K RAM: 9 | * 1. out(t)=Screen[address(t)](t) 10 | * 2. If load(t-1) then Screen[address(t-1)](t)=in(t-1) 11 | * 12 | * The built-in chip implementation has the side effect of continuously 13 | * refreshing a visual 256 by 512 black-and-white screen, simulated 14 | * by the simulator. Each row in the visual screen is represented 15 | * by 32 consecutive 16-bit words, starting at the top left corner 16 | * of the visual screen. Thus the pixel at row r from the top and 17 | * column c from the left (0<=r<=255, 0<=c<=511) reflects the c%16 18 | * bit (counting from LSB to MSB) of the word found in 19 | * Screen[r*32+c/16]. 20 | */ 21 | 22 | CHIP Screen { 23 | 24 | IN in[16], // what to write 25 | load, // write-enable bit 26 | address[13]; // where to read/write 27 | OUT out[16]; // Screen value at the given address 28 | 29 | BUILTIN Screen; 30 | CLOCKED in, load; 31 | } 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /InstallDir/builtInChips/Xor.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/Xor.hdl 5 | 6 | /** 7 | * Exclusive-or gate. out = a xor b. 8 | */ 9 | 10 | CHIP Xor { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN Xor; 16 | } 17 | -------------------------------------------------------------------------------- /SimulatorsGUIPackage/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | SimulatorsGUIPackage 12 | jar 13 | 14 | Simulators GUI package 15 | http://nand2tetris.org 16 | 17 | 18 | 19 | org.nand2tetris 20 | HackGUIPackage 21 | 22 | 23 | 24 | org.nand2tetris 25 | SimulatorsPackage 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /SimulatorsGUIPackage/src/main/java/SimulatorsGUI/PinValueListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package SimulatorsGUI; 19 | 20 | /** 21 | * An interface for objects that wants to listen to PinValueEvent. 22 | */ 23 | public interface PinValueListener { 24 | 25 | /** 26 | * Called when there was a change in one of the pin values. 27 | * The event contains the changed value in a string representation and 28 | * a boolean which is true if the user pressed the 'ok' button and false 29 | * if the user pressed the 'cancel' button. 30 | */ 31 | public void pinValueChanged (PinValueEvent e); 32 | } 33 | 34 | -------------------------------------------------------------------------------- /SimulatorsPackage/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | SimulatorsPackage 12 | jar 13 | 14 | Simulators package 15 | http://nand2tetris.org 16 | 17 | 18 | 19 | org.nand2tetris 20 | HackPackage 21 | 22 | 23 | 24 | org.nand2tetris 25 | CompilersPackage 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/Gates/DirtyGateListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Gates; 19 | 20 | /** 21 | * An interface for objects that want to be notified on a change in the isDirty 22 | * state of a gate. 23 | */ 24 | public interface DirtyGateListener { 25 | 26 | /** 27 | * Executed when a gate becomes dirty. 28 | */ 29 | public void gotDirty(); 30 | 31 | /** 32 | * Executed when a gate becomes clean. 33 | */ 34 | public void gotClean(); 35 | } 36 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/Gates/GateClassUnderLoad.java: -------------------------------------------------------------------------------- 1 | package Hack.Gates; 2 | 3 | public class GateClassUnderLoad extends GateClass { 4 | protected GateClassUnderLoad(String gateName) { 5 | super(gateName, new PinInfo[0], new PinInfo[0]); 6 | } 7 | 8 | @Override 9 | public Gate newInstance() throws InstantiationException { 10 | throw new InstantiationException(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/Gates/GateErrorEvent.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Gates; 19 | 20 | import Hack.Events.*; 21 | 22 | /** 23 | * An event for notifying a GateErrorEventListener on an error that occured 24 | * in a gate. 25 | */ 26 | public class GateErrorEvent extends ErrorEvent { 27 | 28 | /** 29 | * Constructs a new GateErrorEvent with the given source (gate) 30 | * and errorMessage. 31 | */ 32 | public GateErrorEvent(Gate source, String errorMessage) { 33 | super(source, errorMessage); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/Gates/GateErrorEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Gates; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the GateErrorEvent. 22 | */ 23 | public interface GateErrorEventListener { 24 | 25 | /** 26 | * Called when an error occured in a gate. 27 | * The event contains the source object and the error message. 28 | */ 29 | public void gateErrorOccured(GateErrorEvent event); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/Gates/GateException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.Gates; 19 | 20 | /** 21 | * An exception for errors in a gate. 22 | */ 23 | public class GateException extends Exception 24 | { 25 | /** 26 | * Constructs a new GateException with the given message. 27 | */ 28 | public GateException(String message) { 29 | super(message); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/HardwareSimulator/PartsGUI.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.HardwareSimulator; 19 | 20 | import Hack.ComputerParts.*; 21 | import Hack.Gates.*; 22 | 23 | /** 24 | * An interface for the GUI of the Parts. 25 | */ 26 | public interface PartsGUI extends ComputerPartGUI { 27 | 28 | /** 29 | * Sets the contents with the given parts (gates) array. 30 | */ 31 | public void setContents(Gate[] parts); 32 | } 33 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/VMEmulator/CallStackGUI.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.VMEmulator; 19 | 20 | import Hack.ComputerParts.*; 21 | import java.util.*; 22 | 23 | /** 24 | * An interface for a GUI of the call stack. 25 | */ 26 | public interface CallStackGUI extends ComputerPartGUI { 27 | 28 | /** 29 | * Sets the stack with the given vector of method names. 30 | */ 31 | public void setContents(Vector names); 32 | } 33 | -------------------------------------------------------------------------------- /SimulatorsPackage/src/main/java/Hack/VMEmulator/VMProgramRowSelectionEventListener.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************** 2 | * The contents of this file are subject to the GNU General Public License * 3 | * (GPL) Version 2 or later (the "License"); you may not use this file except * 4 | * in compliance with the License. You may obtain a copy of the License at * 5 | * http://www.gnu.org/copyleft/gpl.html * 6 | * * 7 | * Software distributed under the License is distributed on an "AS IS" basis, * 8 | * without warranty of any kind, either expressed or implied. See the License * 9 | * for the specific language governing rights and limitations under the * 10 | * License. * 11 | * * 12 | * This file was originally developed as part of the software suite that * 13 | * supports the book "The Elements of Computing Systems" by Nisan and Schocken, * 14 | * MIT Press 2005. If you modify the contents of this file, please document and * 15 | * mark your changes clearly, for the benefit of others. * 16 | ********************************************************************************/ 17 | 18 | package Hack.VMEmulator; 19 | 20 | /** 21 | * An interface for objects that wants to listen to the VMProgramRowSelectionEvent. 22 | */ 23 | public interface VMProgramRowSelectionEventListener { 24 | 25 | /** 26 | * Called when a new row is selected in the VMProgram. 27 | * The event contains the source object and the selected row instruction and index. 28 | */ 29 | public void rowSelected(VMProgramRowSelectionEvent event); 30 | } 31 | -------------------------------------------------------------------------------- /TextComparer/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | 6 | org.nand2tetris 7 | parent 8 | 2.7.1-SNAPSHOT 9 | 10 | 11 | TextComparer 12 | jar 13 | 14 | Text comparer 15 | http://nand2tetris.org 16 | 17 | 18 | 19 | 20 | org.apache.maven.plugins 21 | maven-shade-plugin 22 | 2.3 23 | 24 | 25 | package 26 | 27 | shade 28 | 29 | 30 | 31 | 32 | TextComparer 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /VMEmulator/src/main/resources/git.properties: -------------------------------------------------------------------------------- 1 | #Default properties, when building without git info 2 | git.dirty=true 3 | git.commit.id.describe-short=unknown 4 | git.build.version=${project.version} 5 | -------------------------------------------------------------------------------- /n2t-software-suite/Assembler.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem $Id: Assembler.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ 4 | rem mark.armbrust@pobox.com 5 | 6 | setlocal 7 | if not "%2"=="" goto :USAGE 8 | if "%~1"=="/?" ( 9 | :USAGE 10 | echo Usage: 11 | echo Assembler Starts the assembler in interactive mode. 12 | echo Assembler FILE[.asm] Assembles FILE.asm to FILE.hack. 13 | exit -b 14 | ) 15 | if not "%~1"=="" ( 16 | set "_arg1=%~f1" 17 | ) 18 | pushd "%~dp0" 19 | if "%~1"=="" ( 20 | start javaw -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Compilers.jar;bin/lib/AssemblerGUI.jar;bin/lib/TranslatorsGUI.jar" ^ 21 | HackAssemblerMain 22 | ) else ( 23 | echo Assembling "%_arg1%" 24 | java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/HackGUI.jar;bin/lib/Compilers.jar;bin/lib/AssemblerGUI.jar;bin/lib/TranslatorsGUI.jar" ^ 25 | HackAssemblerMain "%_arg1%" 26 | ) 27 | popd 28 | -------------------------------------------------------------------------------- /n2t-software-suite/Assembler.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # $Id: Assembler.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ 4 | # mark.armbrust@pobox.com 5 | 6 | # User's CDPATH can interfere with cd in this script 7 | unset CDPATH 8 | # Get the true name of this script 9 | script="`test -L "$0" && readlink -n "$0" || echo "$0"`" 10 | dir="$PWD" 11 | cd "`dirname "$script"`" 12 | if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] 13 | then 14 | echo "Usage:" 15 | echo " `basename "$0"` Starts the assembler in interactive mode." 16 | echo " `basename "$0"` FILE[.asm] Assembles FILE.asm to FILE.hack." 17 | elif [ $# -eq 0 ] 18 | then 19 | # Run assembler in interactive mode 20 | java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Compilers.jar:bin/lib/AssemblerGUI.jar:bin/lib/TranslatorsGUI.jar" HackAssemblerMain & 21 | else 22 | # Convert arg1 to an absolute path and run assembler with arg1. 23 | if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] 24 | then 25 | arg1="$1" 26 | else 27 | arg1="${dir}/$1" 28 | fi 29 | echo Assembling "$arg1" 30 | java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/HackGUI.jar:bin/lib/Compilers.jar:bin/lib/AssemblerGUI.jar:bin/lib/TranslatorsGUI.jar" HackAssemblerMain "$arg1" 31 | fi 32 | 33 | -------------------------------------------------------------------------------- /n2t-software-suite/CPUEmulator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem $Id: CPUEmulator.bat,v 1.3 2014/05/10 00:52:43 marka Exp $ 4 | rem mark.armbrust@pobox.com 5 | 6 | setlocal 7 | if not "%2"=="" goto :USAGE 8 | if "%~1"=="/?" ( 9 | :USAGE 10 | echo Usage: 11 | echo CPUEmulator Starts the CPU Emulator in interactive mode. 12 | echo CPUEmulator FILE.tst Starts the CPU Emulator and runs the FILE.tst 13 | echo test script. The success/failure message 14 | echo is printed to the command console. 15 | exit -b 16 | ) 17 | if not "%~1"=="" ( 18 | set "_arg1=%~f1" 19 | ) 20 | pushd "%~dp0" 21 | if "%~1"=="" ( 22 | start javaw -jar bin/CPUEmulator.jar 23 | ) else ( 24 | rem echo Running "%_arg1%" 25 | java -jar bin/CPUEmulator.jar "%_arg1%" 26 | ) 27 | popd 28 | -------------------------------------------------------------------------------- /n2t-software-suite/CPUEmulator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # $Id: CPUEmulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ 4 | # mark.armbrust@pobox.com 5 | 6 | # User's CDPATH can interfere with cd in this script 7 | unset CDPATH 8 | # Get the true name of this script 9 | script="`test -L "$0" && readlink -n "$0" || echo "$0"`" 10 | dir="$PWD" 11 | cd "`dirname "$script"`" 12 | if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] 13 | then 14 | echo "Usage:" 15 | echo " `basename "$0"` Starts the CPU Emulator in interactive mode." 16 | echo " `basename "$0"` FILE.tst Starts the CPU Emulator and runs the File.tst" 17 | echo " test script. The success/failure message" 18 | echo " is printed to the command console." 19 | elif [ $# -eq 0 ] 20 | then 21 | # Run CPU emulator in interactive mode 22 | java -jar bin/CPUEmulator.jar 23 | else 24 | # Convert arg1 to an absolute path and run CPU emulator with arg1 25 | if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] 26 | then 27 | arg1="$1" 28 | else 29 | arg1="${dir}/$1" 30 | fi 31 | # echo Running "$arg1" 32 | java -jar bin/CPUEmulator.jar "$arg1" 33 | fi 34 | -------------------------------------------------------------------------------- /n2t-software-suite/HardwareSimulator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem $Id: HardwareSimulator.bat,v 1.3 2014/05/10 00:52:43 marka Exp $ 4 | rem mark.armbrust@pobox.com 5 | 6 | setlocal 7 | if not "%2"=="" goto :USAGE 8 | if "%~1"=="/?" ( 9 | :USAGE 10 | echo Usage: 11 | echo HardwareSimulator Starts the Hardware Simulator in 12 | echo interactive mode. 13 | echo HardwareSimulator FILE.tst Starts the Hardware Simulator and runs the 14 | echo FILE.tst test script. The success/failure 15 | echo message is printed to the command console. 16 | exit -b 17 | ) 18 | if not "%~1"=="" ( 19 | set "_arg1=%~f1" 20 | ) 21 | pushd "%~dp0" 22 | if "%~1"=="" ( 23 | start javaw -jar bin/HardwareSimulator.jar 24 | ) else ( 25 | rem echo Running "%_arg1%" 26 | java -jar bin/HardwareSimulator.jar "%_arg1%" 27 | ) 28 | popd 29 | -------------------------------------------------------------------------------- /n2t-software-suite/HardwareSimulator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # $Id: HardwareSimulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ 4 | # mark.armbrust@pobox.com 5 | 6 | # User's CDPATH can interfere with cd in this script 7 | unset CDPATH 8 | # Get the true name of this script 9 | script="`test -L "$0" && readlink -n "$0" || echo "$0"`" 10 | dir="$PWD" 11 | cd "`dirname "$script"`" 12 | if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] 13 | then 14 | echo "Usage:" 15 | echo " `basename "$0"` Starts the Hardware Simulator in" 16 | echo " interactive mode." 17 | echo " `basename "$0"` FILE.tst Starts the Hardware Simulator and runs the" 18 | echo " FILE.tst test script. The success/failure" 19 | echo " message is printed to the command console." 20 | elif [ $# -eq 0 ] 21 | then 22 | # Run hardware simulator in interactive mode 23 | java -jar bin/HardwareSimulator.jar 24 | else 25 | # Convert arg1 to an absolute path and run hardware simulator with arg1 26 | if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] 27 | then 28 | arg1="$1" 29 | else 30 | arg1="${dir}/$1" 31 | fi 32 | # echo Running "$arg1" 33 | java -jar bin/HardwareSimulator.jar "$arg1" 34 | fi 35 | -------------------------------------------------------------------------------- /n2t-software-suite/JackCompiler.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem $Id: JackCompiler.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ 4 | rem mark.armbrust@pobox.com 5 | 6 | setlocal 7 | if not "%2"=="" goto :USAGE 8 | if "%~1"=="/?" ( 9 | :USAGE 10 | echo Usage: 11 | echo JackCompiler Compiles all .jack files in the current 12 | echo working directory. 13 | echo JackCompiler DIRECTORY Compiles all .jack files in DIRECTORY. 14 | echo JackCompiler FILE.jack Compiles FILE.jack to FILE.vm. 15 | exit -b 16 | ) 17 | if not "%~1"=="" ( 18 | set "_arg1=%~f1" 19 | ) else ( 20 | set "_arg1=%CD%" 21 | ) 22 | pushd "%~dp0" 23 | echo Compiling "%_arg1%" 24 | java -classpath "%CLASSPATH%;bin/classes;bin/lib/Hack.jar;bin/lib/Compilers.jar" ^ 25 | Hack.Compiler.JackCompiler "%_arg1%" 26 | popd 27 | -------------------------------------------------------------------------------- /n2t-software-suite/JackCompiler.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # $Id: JackCompiler.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ 4 | # mark.armbrust@pobox.com 5 | 6 | # User's CDPATH can interfere with cd in this script 7 | unset CDPATH 8 | # Get the true name of this script 9 | script="`test -L "$0" && readlink -n "$0" || echo "$0"`" 10 | dir="$PWD" 11 | cd "`dirname "$script"`" 12 | if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] 13 | then 14 | echo "Usage:" 15 | echo " `basename "$0"` Compiles all .jack files in the current" 16 | echo " working directory." 17 | echo " `basename "$0"` DIRECTORY Compiles all .jack files in DIRECTORY." 18 | echo " `basename "$0"` FILE.jack Compiles FILE.jack to FILE.vm." 19 | else 20 | if [ $# -eq 0 ] 21 | then 22 | # Use current directory as arg1 23 | arg1="$dir" 24 | else 25 | # Convert arg1 to an absolute path 26 | if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] 27 | then 28 | arg1="$1" 29 | else 30 | arg1="$dir/$1" 31 | fi 32 | fi 33 | echo Compiling "$arg1" 34 | java -classpath "${CLASSPATH}:bin/classes:bin/lib/Hack.jar:bin/lib/Compilers.jar" Hack.Compiler.JackCompiler "$arg1" 35 | fi 36 | -------------------------------------------------------------------------------- /n2t-software-suite/Linux-CPUEmulator.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Nand2Tetris CPU Emulator 5 | Exec=/bin/bash -c 'cd `dirname %k` && ./CPUEmulator.sh %f' 6 | Categories=Development;IDE; 7 | Terminal=false 8 | -------------------------------------------------------------------------------- /n2t-software-suite/Linux-HadrwareSimulator.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Nand2Tetris Hardware Simulator 5 | Exec=/bin/bash -c 'cd `dirname %k` && ./HardwareSimulator.sh %f' 6 | Categories=Development;IDE; 7 | Terminal=false 8 | -------------------------------------------------------------------------------- /n2t-software-suite/Linux-VMEmulator.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=Nand2Tetris VM Emulator 5 | Exec=/bin/bash -c 'cd `dirname %k` && ./VMEmulator.sh %f' 6 | Categories=Development;IDE; 7 | Terminal=false 8 | -------------------------------------------------------------------------------- /n2t-software-suite/OS/Array.vm: -------------------------------------------------------------------------------- 1 | function Array.new 0 2 | push argument 0 3 | push constant 0 4 | gt 5 | not 6 | if-goto IF_TRUE0 7 | goto IF_FALSE0 8 | label IF_TRUE0 9 | push constant 2 10 | call Sys.error 1 11 | pop temp 0 12 | label IF_FALSE0 13 | push argument 0 14 | call Memory.alloc 1 15 | return 16 | function Array.dispose 0 17 | push argument 0 18 | pop pointer 0 19 | push pointer 0 20 | call Memory.deAlloc 1 21 | pop temp 0 22 | push constant 0 23 | return 24 | -------------------------------------------------------------------------------- /n2t-software-suite/OS/Sys.vm: -------------------------------------------------------------------------------- 1 | function Sys.init 0 2 | call Memory.init 0 3 | pop temp 0 4 | call Math.init 0 5 | pop temp 0 6 | call Screen.init 0 7 | pop temp 0 8 | call Output.init 0 9 | pop temp 0 10 | call Keyboard.init 0 11 | pop temp 0 12 | call Main.main 0 13 | pop temp 0 14 | call Sys.halt 0 15 | pop temp 0 16 | push constant 0 17 | return 18 | function Sys.halt 0 19 | label WHILE_EXP0 20 | push constant 0 21 | not 22 | not 23 | if-goto WHILE_END0 24 | goto WHILE_EXP0 25 | label WHILE_END0 26 | push constant 0 27 | return 28 | function Sys.wait 1 29 | push argument 0 30 | push constant 0 31 | lt 32 | if-goto IF_TRUE0 33 | goto IF_FALSE0 34 | label IF_TRUE0 35 | push constant 1 36 | call Sys.error 1 37 | pop temp 0 38 | label IF_FALSE0 39 | label WHILE_EXP0 40 | push argument 0 41 | push constant 0 42 | gt 43 | not 44 | if-goto WHILE_END0 45 | push constant 50 46 | pop local 0 47 | label WHILE_EXP1 48 | push local 0 49 | push constant 0 50 | gt 51 | not 52 | if-goto WHILE_END1 53 | push local 0 54 | push constant 1 55 | sub 56 | pop local 0 57 | goto WHILE_EXP1 58 | label WHILE_END1 59 | push argument 0 60 | push constant 1 61 | sub 62 | pop argument 0 63 | goto WHILE_EXP0 64 | label WHILE_END0 65 | push constant 0 66 | return 67 | function Sys.error 0 68 | push constant 69 69 | call Output.printChar 1 70 | pop temp 0 71 | push constant 82 72 | call Output.printChar 1 73 | pop temp 0 74 | push constant 82 75 | call Output.printChar 1 76 | pop temp 0 77 | push argument 0 78 | call Output.printInt 1 79 | pop temp 0 80 | call Sys.halt 0 81 | pop temp 0 82 | push constant 0 83 | return 84 | -------------------------------------------------------------------------------- /n2t-software-suite/TextComparer.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem $Id: TextComparer.bat,v 1.2 2014/05/10 00:52:43 marka Exp $ 4 | rem mark.armbrust@pobox.com 5 | 6 | setlocal 7 | if not "%3"=="" goto :USAGE 8 | if "%1"=="/?" goto :USAGE 9 | if not "%~1"=="" ( 10 | set "_arg1=%~f1" 11 | ) 12 | if not "%~2"=="" ( 13 | set "_arg2=%~f2" 14 | ) 15 | pushd "%~dp0" 16 | if NOT "%~1"=="" ( 17 | if NOT "%~2"=="" ( 18 | java -classpath "%CLASSPATH%;bin/classes" TextComparer ^ 19 | "%_arg1%" "%_arg2%" 20 | popd 21 | exit /B 22 | ) 23 | ) 24 | :USAGE 25 | echo Usage: 26 | echo TextComparer FILE1 FILE2 Compares FILE1 and FILE2. The success 27 | echo message or the first miscompared line 28 | echo is printed to the command console. 29 | popd 30 | -------------------------------------------------------------------------------- /n2t-software-suite/TextComparer.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # $Id: TextComparer.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ 4 | # mark.armbrust@pobox.com 5 | 6 | # User's CDPATH can interfere with cd in this script 7 | unset CDPATH 8 | # Get the true name of this script 9 | script="`test -L "$0" && readlink -n "$0" || echo "$0"`" 10 | dir="$PWD" 11 | cd "`dirname "$script"`" 12 | if [ \( $# -ne 2 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] 13 | then 14 | # print usage 15 | echo "Usage:" 16 | echo " `basename "$0"` FILE1 FILE2 Compares FILE1 and FILE2. The success" 17 | echo " message or the first miscompared line" 18 | echo " is printed to the command console." 19 | else 20 | # Convert arg1 to an absolute path 21 | if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] 22 | then 23 | arg1="$1" 24 | else 25 | arg1="$dir/$1" 26 | fi 27 | # Convert arg2 to an absolute path 28 | if [ `echo "$2" | sed -e "s/\(.\).*/\1/"` = / ] 29 | then 30 | arg2="$2" 31 | else 32 | arg2="$dir/$2" 33 | fi 34 | # echo Comparing "$arg1" "$arg2" 35 | java -classpath "${CLASSPATH}:bin/classes" TextComparer "$arg1" "$arg2" 36 | fi 37 | -------------------------------------------------------------------------------- /n2t-software-suite/VMEmulator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | rem $Id: VMEmulator.bat,v 1.3 2014/05/10 00:51:55 marka Exp $ 4 | rem mark.armbrust@pobox.com 5 | 6 | setlocal 7 | if not "%2"=="" goto :USAGE 8 | if "%~1"=="/?" ( 9 | :USAGE 10 | echo Usage: 11 | echo VMEmulator Starts the VM Emulator in interactive mode. 12 | echo VMEmulator FILE.tst Starts the VM Emulator and runs the FILE.tst test 13 | echo script. The success/failure message is 14 | echo printed to the command console. 15 | exit -b 16 | ) 17 | if not "%~1"=="" ( 18 | set "_arg1=%~f1" 19 | ) 20 | pushd "%~dp0" 21 | if "%~1"=="" ( 22 | start javaw -jar bin/VMEmulator.jar 23 | ) else ( 24 | rem echo Running "%_arg1%" 25 | if "%N2T_VM_USE_BUILTINS%"=="" set N2T_VM_USE_BUILTINS=yes 26 | java -jar bin/VMEmulator.jar "%_arg1%" 27 | ) 28 | popd 29 | -------------------------------------------------------------------------------- /n2t-software-suite/VMEmulator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # $Id: VMEmulator.sh,v 1.1 2014/06/17 21:14:01 marka Exp $ 4 | # mark.armbrust@pobox.com 5 | 6 | # User's CDPATH can interfere with cd in this script 7 | unset CDPATH 8 | # Get the true name of this script 9 | script="`test -L "$0" && readlink -n "$0" || echo "$0"`" 10 | dir="$PWD" 11 | cd "`dirname "$script"`" 12 | if [ \( $# -gt 1 \) -o \( "$1" = "-h" \) -o \( "$1" = "--help" \) ] 13 | then 14 | echo "Usage:" 15 | echo " `basename "$0"` Starts the VM Emulator in interactive mode." 16 | echo " `basename "$0"` FILE.tst Starts the VM Emulator and runs the FILE.tst test" 17 | echo " script. The success/failure message is" 18 | echo " printed to the command console." 19 | elif [ $# -eq 0 ] 20 | then 21 | # Run VM emulator in interactive mode 22 | java -jar bin/VMEmulator.jar 23 | else 24 | # Convert arg1 to an absolute path and run VM emulator with arg1 25 | if [ `echo "$1" | sed -e "s/\(.\).*/\1/"` = / ] 26 | then 27 | arg1="$1" 28 | else 29 | arg1="${dir}/$1" 30 | fi 31 | # echo Running "$arg1" 32 | [ -z "$N2T_VM_USE_BUILTINS" ] && export N2T_VM_USE_BUILTINS="yes" 33 | java -jar bin/VMEmulator.jar "$arg1" 34 | fi 35 | -------------------------------------------------------------------------------- /n2t-software-suite/bin/classes/CPUEmulatorMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/classes/CPUEmulatorMain.class -------------------------------------------------------------------------------- /n2t-software-suite/bin/classes/HackAssemblerMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/classes/HackAssemblerMain.class -------------------------------------------------------------------------------- /n2t-software-suite/bin/classes/HardwareSimulatorMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/classes/HardwareSimulatorMain.class -------------------------------------------------------------------------------- /n2t-software-suite/bin/classes/TextComparer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/classes/TextComparer.class -------------------------------------------------------------------------------- /n2t-software-suite/bin/classes/VMEmulatorMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/classes/VMEmulatorMain.class -------------------------------------------------------------------------------- /n2t-software-suite/bin/help/compiler.txt: -------------------------------------------------------------------------------- 1 | Jack Compiler, Version 2.5 2 | 3 | This program is part of www.nand2tetris.org 4 | and the book "The Elements of Computing Systems" 5 | by Nisan and Schocken, MIT Press. 6 | 7 | Software Architects: Yaron Ukrainitz and Yannai A. Gonczarowski 8 | 9 | Usage instruction and tips can be found in the relevant book chapters. 10 | -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/arrow2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/arrow2.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/calculator2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/calculator2.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/cancel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/cancel.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/chip.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/chip.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/clock2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/clock2.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/equal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/equal.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/find.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/find.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/hex.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/hex.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/keyboard.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/keyboard.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/ok.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/ok.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/ok2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/ok2.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/open.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/open.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/open2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/open2.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/opendoc.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/opendoc.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/redflag.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/redflag.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/save.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/save.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/scroll.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/scroll.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/smallcancel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/smallcancel.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/smallequal.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/smallequal.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/smallminus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/smallminus.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/smallnew.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/smallnew.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/smallok.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/smallok.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/smallplus.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/smallplus.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/vcrfastforward.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/vcrfastforward.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/vcrforward.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/vcrforward.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/vcrrewind.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/vcrrewind.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/vcrstepover.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/vcrstepover.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/images/vcrstop.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/images/vcrstop.gif -------------------------------------------------------------------------------- /n2t-software-suite/bin/lib/AssemblerGUI.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/lib/AssemblerGUI.jar -------------------------------------------------------------------------------- /n2t-software-suite/bin/lib/Compilers.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/lib/Compilers.jar -------------------------------------------------------------------------------- /n2t-software-suite/bin/lib/Hack.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/lib/Hack.jar -------------------------------------------------------------------------------- /n2t-software-suite/bin/lib/HackGUI.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/lib/HackGUI.jar -------------------------------------------------------------------------------- /n2t-software-suite/bin/lib/Simulators.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/lib/Simulators.jar -------------------------------------------------------------------------------- /n2t-software-suite/bin/lib/SimulatorsGUI.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/lib/SimulatorsGUI.jar -------------------------------------------------------------------------------- /n2t-software-suite/bin/lib/TranslatorsGUI.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/bin/lib/TranslatorsGUI.jar -------------------------------------------------------------------------------- /n2t-software-suite/bin/scripts/defaultCPU.txt: -------------------------------------------------------------------------------- 1 | repeat { 2 | ticktock; 3 | } -------------------------------------------------------------------------------- /n2t-software-suite/bin/scripts/defaultHW.txt: -------------------------------------------------------------------------------- 1 | repeat { 2 | tick, 3 | tock; 4 | } -------------------------------------------------------------------------------- /n2t-software-suite/bin/scripts/defaultVM.txt: -------------------------------------------------------------------------------- 1 | repeat { 2 | vmstep; 3 | } -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/ALU.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/ALU.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/ALU.hdl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/ALU.hdl -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/ARegister.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/ARegister.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/ARegister.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/ARegister.hdl 5 | 6 | /** 7 | * A 16-Bit register called "A Register". 8 | * If load[t-1]=1 then out[t] = in[t-1] 9 | * else out does not change (out[t] = out[t-1]) 10 | * 11 | * This built-in chip implementation has the side effect of 12 | * providing a GUI representation of a 16-bit register 13 | * called "A register" (typically used to store an address). 14 | */ 15 | 16 | CHIP ARegister { 17 | 18 | IN in[16], load; 19 | OUT out[16]; 20 | 21 | BUILTIN ARegister; 22 | CLOCKED in, load; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Add16.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Add16.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Add16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Add16.hdl 5 | 6 | /* 7 | * Adds two 16-bit values. 8 | * The most significant carry bit is ignored. 9 | */ 10 | 11 | CHIP Add16 { 12 | 13 | IN a[16], b[16]; 14 | OUT out[16]; 15 | 16 | BUILTIN Add16; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/And.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/And.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/And.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/And.hdl 5 | 6 | /** 7 | * And gate: out = 1 if {a == 1 and b == 1}, 0 otherwise 8 | */ 9 | 10 | CHIP And { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN And; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/And16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/And16.hdl 5 | 6 | /** 7 | * 16-bit-wise And gate: for i = 0..15: out[i] = a[i] and b[i] 8 | */ 9 | 10 | CHIP And16 { 11 | 12 | IN a[16], b[16]; 13 | OUT out[16]; 14 | 15 | BUILTIN And; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Bit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Bit.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Bit.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Bit.hdl 5 | 6 | /** 7 | * 1-bit register. 8 | * If load[t] == 1 then out[t+1] = in[t] 9 | * else out[t+1] = out[t] (no change) 10 | */ 11 | 12 | CHIP Bit { 13 | 14 | IN in, load; 15 | OUT out; 16 | 17 | BUILTIN Bit; 18 | CLOCKED in, load; 19 | } 20 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DFF.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/DFF.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DFF.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/DFF.hdl 5 | 6 | /** 7 | * Data Flip-flop: out(t) = in(t-1) 8 | * where t is the current time unit, or clock cycle. 9 | */ 10 | 11 | CHIP DFF { 12 | 13 | IN in; 14 | OUT out; 15 | 16 | BUILTIN DFF; 17 | CLOCKED in; 18 | } 19 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DMux.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/DMux.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DMux.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/DMux.hdl 5 | 6 | /** 7 | * Dmultiplexor. 8 | * {a,b} = {in,0} if sel == 0 9 | * {0,in} if sel == 1 10 | */ 11 | 12 | 13 | CHIP DMux { 14 | 15 | IN in, sel; 16 | OUT a, b; 17 | 18 | BUILTIN DMux; 19 | } 20 | 21 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DMux4Way.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/DMux4Way.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DMux4Way.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/DMux4Way.hdl 5 | 6 | /** 7 | * 4-way demultiplexor. 8 | * {a,b,c,d} = {in,0,0,0} if sel == 00 9 | * {0,in,0,0} if sel == 01 10 | * {0,0,in,0} if sel == 10 11 | * {0,0,0,in} if sel == 11 12 | */ 13 | 14 | 15 | CHIP DMux4Way { 16 | 17 | IN in, sel[2]; 18 | OUT a, b, c, d; 19 | 20 | BUILTIN DMux4Way; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DMux8Way.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/DMux8Way.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DMux8Way.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/DMux8Way.hdl 5 | 6 | /** 7 | * 8-way demultiplexor. 8 | * {a,b,c,d,e,f,g,h} = {in,0,0,0,0,0,0,0} if sel == 000 9 | * {0,in,0,0,0,0,0,0} if sel == 001 10 | * etc. 11 | * {0,0,0,0,0,0,0,in} if sel == 111 12 | */ 13 | 14 | 15 | CHIP DMux8Way { 16 | 17 | IN in, sel[3]; 18 | OUT a, b, c, d, e, f, g, h; 19 | 20 | BUILTIN DMux8Way; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DRegister.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/DRegister.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/DRegister.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of the materials accompanying the book 2 | // "The Elements of Computing Systems" by Nisan and Schocken, 3 | // MIT Press. Book site: www.idc.ac.il/tecs 4 | // File name: tools/builtIn/DRegister.hdl 5 | 6 | /** 7 | * A 16-Bit register called "D Register". 8 | * If load[t-1]=1 then out[t] = in[t-1] 9 | * else out does not change (out[t] = out[t-1]) 10 | * 11 | * This built-in chip implementation has the side effect of 12 | * providing a GUI representation of a 16-bit register 13 | * called "D register" (typically used to store data). 14 | */ 15 | 16 | CHIP DRegister { 17 | 18 | IN in[16], load; 19 | OUT out[16]; 20 | 21 | BUILTIN DRegister; 22 | CLOCKED in, load; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/FullAdder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/FullAdder.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/FullAdder.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/FullAdder.hdl 5 | 6 | /** 7 | * Full adder. Computes sum, the least significant bit of 8 | * a + b + c, and carry, the most significant bit of a + b + c. 9 | */ 10 | 11 | CHIP FullAdder { 12 | 13 | IN a, b, c; 14 | OUT sum, // LSB of a + b + c 15 | carry; // MSB of a + b + c 16 | 17 | BUILTIN FullAdder; 18 | } 19 | 20 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/HalfAdder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/HalfAdder.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/HalfAdder.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/HalfAdder.hdl 5 | 6 | /** 7 | * Half adder. Computes sum, the least significnat bit of a + b, 8 | * and carry, the most significnat bit of a + b. 9 | */ 10 | 11 | CHIP HalfAdder { 12 | 13 | IN a, b; 14 | OUT sum, // LSB of a + b 15 | carry; // MSB of a + b 16 | 17 | BUILTIN HalfAdder; 18 | } 19 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Inc16.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Inc16.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Inc16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Inc16.hdl 5 | 6 | /** 7 | * 16-bit incrementer. out = in + 1 (16-bit addition). 8 | * Overflow is neither detected nor handled. 9 | */ 10 | 11 | CHIP Inc16 { 12 | 13 | IN in[16]; 14 | OUT out[16]; 15 | 16 | BUILTIN Inc16; 17 | } 18 | 19 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Keyboard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Keyboard.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Keyboard.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Keyboard.hdl 5 | 6 | /** 7 | * The keyboard (memory map). 8 | * Outputs the code of the currently pressed key. 9 | * 10 | * The built-in chip implementation has two side effects supplied 11 | * by the simulator. First, the keyboard memory map is continuously 12 | * being refreshed from the physical keyboard unit. Second, it 13 | * displays a keyboard icon and data entry GUI. 14 | */ 15 | 16 | CHIP Keyboard { 17 | 18 | OUT out[16]; // The ASCII code of the pressed key, 19 | // or 0 if no key is currently pressed, 20 | // or one the special codes listed in Figure 5.5. 21 | 22 | BUILTIN Keyboard; 23 | } 24 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Mux.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Mux.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Mux.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Mux.hdl 5 | 6 | /** 7 | * Multiplexor. If sel == 1 then out = b else out = a. 8 | */ 9 | 10 | CHIP Mux { 11 | 12 | IN a, b, sel; 13 | OUT out; 14 | 15 | BUILTIN Mux; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Mux16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Mux16.hdl 5 | 6 | /** 7 | * 16 bit multiplexor. If sel == 1 then out = b else out = a. 8 | */ 9 | 10 | CHIP Mux16 { 11 | 12 | IN a[16], b[16], sel; 13 | OUT out[16]; 14 | 15 | BUILTIN Mux; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Mux4Way16.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Mux4Way16.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Mux4Way16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Mux4Way16.hdl 5 | 6 | /** 7 | * 4-way 16-bit multiplexor. 8 | * out = a if sel == 00 9 | * b if sel == 01 10 | * c if sel == 10 11 | * d if sel == 11 12 | */ 13 | 14 | 15 | CHIP Mux4Way16 { 16 | 17 | IN a[16], b[16], c[16], d[16], sel[2]; 18 | OUT out[16]; 19 | 20 | BUILTIN Mux4Way16; 21 | } 22 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Mux8Way16.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Mux8Way16.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Mux8Way16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Mux8Way16.hdl 5 | 6 | /** 7 | * 8-way 16-bit multiplexor. 8 | * out = a if sel == 000 9 | * b if sel == 001 10 | * etc. 11 | * h if sel == 111 12 | */ 13 | 14 | 15 | CHIP Mux8Way16 { 16 | 17 | IN a[16], b[16], c[16], d[16], 18 | e[16], f[16], g[16], h[16], 19 | sel[3]; 20 | 21 | OUT out[16]; 22 | 23 | BUILTIN Mux8Way16; 24 | } -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Nand.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Nand.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Nand.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Nand.hdl 5 | 6 | /** 7 | * Nand gate: out = a Nand b. 8 | */ 9 | 10 | CHIP Nand { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN Nand; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Not.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Not.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Not.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Not.hdl 5 | 6 | /** 7 | * Not gate: out = not in 8 | */ 9 | 10 | CHIP Not { 11 | 12 | IN in; 13 | OUT out; 14 | 15 | BUILTIN Not; 16 | } -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Not16.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Not16.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Not16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Not16.hdl 5 | 6 | /** 7 | * 16-bit Not gate: for i = 0..15: out[i] = not in[i] 8 | */ 9 | 10 | CHIP Not16 { 11 | 12 | IN in[16]; 13 | OUT out[16]; 14 | 15 | BUILTIN Not16; 16 | } -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Or.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Or.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Or.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Or.hdl 5 | 6 | /** 7 | * Or gate: out = 1 if {a == 1 or b == 1}, 0 otherwise 8 | */ 9 | 10 | CHIP Or { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN Or; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Or16.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Or16.hdl 5 | 6 | /** 7 | * 16-bit bitwise Or gate: for i = 0..15 out[i] = a[i] or b[i]. 8 | */ 9 | 10 | CHIP Or16 { 11 | 12 | IN a[16], b[16]; 13 | OUT out[16]; 14 | 15 | BUILTIN Or; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Or8Way.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Or8Way.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Or8Way.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Or8Way.hdl 5 | 6 | /** 7 | * 8-way Or gate: out = in[0] or in[1] or ... or in[7]. 8 | */ 9 | 10 | CHIP Or8Way { 11 | 12 | IN in[8]; 13 | OUT out; 14 | 15 | BUILTIN Or8Way; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/PC.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/PC.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/PC.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/PC.hdl 5 | 6 | /** 7 | * 16-bit counter with load and reset controls. 8 | * 9 | * If reset(t-1) then out(t) = 0 10 | * else if load(t-1) then out(t) = in(t-1) 11 | * else if inc(t-1) then out(t) = out(t-1) + 1 (integer addition) 12 | * else out(t) = out(t-1) 13 | */ 14 | 15 | CHIP PC { 16 | 17 | IN in[16], load, inc, reset; 18 | OUT out[16]; 19 | 20 | BUILTIN PC; 21 | CLOCKED in, load, inc, reset; 22 | } 23 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/RAM.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM16K.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/RAM16K.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM16K.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/RAM16K.hdl 5 | 6 | /** 7 | * Memory of 16K registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM16K[address(t)](t) 10 | * Write: If load(t-1) then RAM16K[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load=1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM16K { 18 | 19 | IN in[16], load, address[14]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM16K; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM4K.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/RAM4K.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM4K.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/RAM4K.hdl 5 | 6 | /** 7 | * Memory of 4K registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM4K[address(t)](t) 10 | * Write: If load(t-1) then RAM4K[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load == 1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM4K { 18 | 19 | IN in[16], load, address[12]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM4K; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM512.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/RAM512.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM512.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/RAM512.hdl 5 | 6 | /** 7 | * Memory of 512 registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM512[address(t)](t) 10 | * Write: If load(t-1) then RAM512[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load == 1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM512 { 18 | 19 | IN in[16], load, address[9]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM512; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM64.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/RAM64.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM64.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/RAM64.hdl 5 | 6 | /** 7 | * Memory of 64 registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM64[address(t)](t) 10 | * Write: If load(t-1) then RAM64[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load == 1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM64 { 18 | 19 | IN in[16], load, address[6]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM64; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/RAM8.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RAM8.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/RAM8.hdl 5 | 6 | /** 7 | * Memory of 8 registers, each 16-bit wide. 8 | * The chip facilitates read and write operations, as follows: 9 | * Read: out(t) = RAM8[address(t)](t) 10 | * Write: If load(t-1) then RAM8[address(t-1)](t) = in(t-1) 11 | * In words: the chip always outputs the value stored at the memory 12 | * location specified by address. If load == 1, the in value is loaded 13 | * into the memory location specified by address. This value becomes 14 | * available through the out output starting from the next time step. 15 | */ 16 | 17 | CHIP RAM8 { 18 | 19 | IN in[16], load, address[3]; 20 | OUT out[16]; 21 | 22 | BUILTIN RAM8; 23 | CLOCKED in, load; 24 | } 25 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/ROM32K.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/ROM32K.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/ROM32K.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/ROM32K.hdl 5 | 6 | /** 7 | * Read-Only memory (ROM) of 16K registers, each 16-bit wide. 8 | * The chip is designed to facilitate data read, as follows: 9 | * out(t) = ROM32K[address(t)](t) 10 | * In words: the chip always outputs the value stored at the 11 | * memory location specified by address. 12 | * 13 | * The built-in chip implementation has a GUI side-effect, 14 | * showing an array-like component that displays the ROM's 15 | * contents. The ROM32K chip is supposed to be pre-loaded with 16 | * a machine language program. To that end, the built-in chip 17 | * implementation also knows how to handle the "ROM32K load Xxx" 18 | * script command, where Xxx is the name of a text file containing 19 | * a program written in the Hack machine language. When the 20 | * simulator encounters such a command in a test script, the code 21 | * found in the file is loaded into the simulated ROM32K unit. 22 | */ 23 | 24 | CHIP ROM32K { 25 | 26 | IN address[15]; 27 | OUT out[16]; 28 | 29 | BUILTIN ROM32K; 30 | } 31 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Register.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Register.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Register.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Register.hdl 5 | 6 | /** 7 | * 16-Bit register. 8 | * If load[t-1]=1 then out[t] = in[t-1] 9 | * else out does not change (out[t] = out[t-1]) 10 | */ 11 | 12 | CHIP Register { 13 | 14 | IN in[16], load; 15 | OUT out[16]; 16 | 17 | BUILTIN Register; 18 | CLOCKED in, load; 19 | } 20 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/RegisterWithGUI.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/RegisterWithGUI.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Screen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Screen.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Screen.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Screen.hdl 5 | 6 | /** 7 | * The Screen (memory map). 8 | * Functions exactly like a 16-bit 8K RAM: 9 | * 1. out(t)=Screen[address(t)](t) 10 | * 2. If load(t-1) then Screen[address(t-1)](t)=in(t-1) 11 | * 12 | * The built-in chip implementation has the side effect of continuously 13 | * refreshing a visual 256 by 512 black-and-white screen, simulated 14 | * by the simulator. Each row in the visual screen is represented 15 | * by 32 consecutive 16-bit words, starting at the top left corner 16 | * of the visual screen. Thus the pixel at row r from the top and 17 | * column c from the left (0<=r<=255, 0<=c<=511) reflects the c%16 18 | * bit (counting from LSB to MSB) of the word found in 19 | * Screen[r*32+c/16]. 20 | */ 21 | 22 | CHIP Screen { 23 | 24 | IN in[16], // what to write 25 | load, // write-enable bit 26 | address[13]; // where to read/write 27 | OUT out[16]; // Screen value at the given address 28 | 29 | BUILTIN Screen; 30 | CLOCKED in, load; 31 | } 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Xor.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInChips/Xor.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInChips/Xor.hdl: -------------------------------------------------------------------------------- 1 | // This file is part of www.nand2tetris.org 2 | // and the book "The Elements of Computing Systems" 3 | // by Nisan and Schocken, MIT Press. 4 | // File name: tools/builtIn/Xor.hdl 5 | 6 | /** 7 | * Exclusive-or gate: out = !(a == b). 8 | */ 9 | 10 | CHIP Xor { 11 | 12 | IN a, b; 13 | OUT out; 14 | 15 | BUILTIN Xor; 16 | } 17 | -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/Array.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/Array.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/JackOSClass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/JackOSClass.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/Keyboard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/Keyboard.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/Math.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/Math.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/Memory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/Memory.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/Output.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/Output.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/Screen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/Screen.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/String.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/String.class -------------------------------------------------------------------------------- /n2t-software-suite/builtInVMCode/Sys.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/itoshkov/nand2tetris-emu/399e449ed8dee8ee99e8902fa7a0bfc17dfb460f/n2t-software-suite/builtInVMCode/Sys.class -------------------------------------------------------------------------------- /prepare-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #set -x 4 | 5 | DIST_NAME=n2t-software-suite 6 | RELEASE_DIR=Release 7 | 8 | cd $(dirname $0) 9 | 10 | rm -rf $RELEASE_DIR 11 | 12 | mvn clean verify 13 | 14 | DIR=$(mktemp -d) 15 | INST_DIR="${DIR}/${DIST_NAME}/bin" 16 | 17 | git archive --format=tar HEAD ${DIST_NAME} | tar -x -C ${DIR} 18 | 19 | cp HardwareSimulator/target/HardwareSimulator-*.jar $INST_DIR/HardwareSimulator.jar 20 | cp CPUEmulator/target/CPUEmulator-*.jar $INST_DIR/CPUEmulator.jar 21 | cp VMEmulator/target/VMEmulator-*.jar $INST_DIR/VMEmulator.jar 22 | 23 | pushd $DIR 24 | zip -r ${DIST_NAME}.zip ${DIST_NAME} 25 | popd 26 | mkdir $RELEASE_DIR 27 | mv $DIR/${DIST_NAME}.zip $RELEASE_DIR 28 | rm -rf $DIR 29 | --------------------------------------------------------------------------------