[1] In using the term “modern”, the authors refer to a digital, binary machine that is patterned according to the von Neumann architecture model.
[2] One such course, created by the authors and delivered in two parts, is freely available as a massive open online course (MOOC) called Build a Modern Computer From First Principles: From Nand to Tetris.
[3] In the twelve projects included in the course, learners start with a two input Nand gate and end up with a fully operational virtual computer, including both hardware (memory and CPU) and software (assembler, VM, Java-like programming language, and OS).
[4] The Hack computer hardware consists of three basic elements as shown in the block diagram.
The address buses (15-bit), as well as the data and instruction busses (16-bit) for the ROM and RAM units are completely independent.
Therefore, the Hack design follows the Harvard architecture model with respect to bus communication between the memory units and the CPU.
The Hack computer’s ROM module is presented as a linear array of individually addressable, sequential, 16-bit memory registers.
The ROM address bus is 15 bits wide, so a total of 32,768 individual words are available for program instructions.
Addresses 0 (0x000) through 16383 (0x3FFF) contain conventional 16-bit, read-write registers and are meant for use as general-purpose program data storage.
Data written to addresses in this range have the side effect of producing output on the computer’s virtual 256 x 512 screen (see I/O).
State transitions of the selected RAM memory register is also coordinated by the system clock signal.
The computation produced as output from the operands is specified by a set of six ordered, single-bit inputs to the ALU.
The CPU also includes logic to change, under program control, the order of the computer's instruction execution, by setting the PC to a non-sequential value.
Step-wise operation of the CPU and memory units is controlled by a clock that is built-in to both the hardware simulator and the computer emulator programs.
At the beginning of a clock cycle the instruction at the ROM address emitted by the current value of the program counter is decoded.
The primary hardware supported data type is the 16-bit signed integer, which is represented in 2’s complement format.
Since the Hack computer hardware has direct support for neither integer multiplication (and division) or function calls, there are no corresponding machine language instructions in the ISA for these operations.
As a side-effect, the RAM register having the address represented by that value is enabled for subsequent read/write action in the next clock cycle.
Label declarations, A-instructions, and C-instructions, as defined below, may not include any internal white-space characters, although leading or trailing whitespace is permitted (and ignored).
All text following the comment identifier character sequence to end of line is completely ignored by the assembler; consequently, they produce no machine code.
Hack assembly language allows the use of alphanumeric symbols for number of different specific purposes.
User defined symbols may be created in an assembly language program to represent variables; that is, a named RAM register.
When the source code is processed by the assembler, the variable symbol is bound to a unique positive integer value in beginning at address 16.
It is noted that the 6 ALU control bits could potentially specify 64 computational functions; however, only the 18 presented in the table are officially documented for recognition by the assembler.
Because the comp field must always be supplied, even though the value is not required for the unconditional branch, the syntax of this instruction is given as “0;JMP”.
Freely available software supporting the Hack computer includes a command line assembler application.
This program illustrates all of the features of the “documented” assembly language capabilities of Hack Computer except memory-mapped I/O.
Note that full-line comments, blank lines, and label definition statements generate no machine language code.
Here the instruction loads the bound label value, representing an address in ROM memory, into the A register and M pseudo-register.
The Hack computer provides no machine language instruction to halt program execution.