Questions tagged [nand2tetris]

For questions regarding the Nand2Tetris course assignments (and the accompanying book "The elements of computing systems") by Shimon Schocken and Noam Nisan. Including the Hack assembly language, the Jack VM and high level languages.

The Nand2Tetris course teaches how to build a modern computer from the first principles, and can be taken by each person with some programming knowledge in any language. All the CS related materials are taught and explained during the course.

The course can be taken in Coursera, and has two parts:

It has an accompanying software that can be found on the website, and a book named The Elements of Computing Systems: Building a Modern Computer from First Principles.

See also: Nand2Tetris forum

116 questions
0
votes
1 answer

Dmux4Way is producing error in line 7: error from Hardware Simulator?

Did I miss anything or is Hardware Simulator wrong? The simulator is producing error! Please can you run this and see the error. Please can you run this and see the error. Please can you run this and see the error. // This file is part of…
0
votes
1 answer

Why does the order of the lines of code not matter in Hardware Description Language?

Per the nand2tetris course material, "Since the language is designed to describe connections rather than processes, the order of the PARTS statements is insignificant: as long as the chip-parts are connected correctly, the chip will function as…
geronimo
  • 1,277
  • 1
  • 10
  • 11
0
votes
1 answer

In subroutine insert: Expected ( error in Jack programming language

I get error In BinarySearchTree.jack (line 20): In subroutine insert: Expected ( In BinarySearchTree.jack (line 25): In subroutine insert: Expected ( I have 2 classes, Node: class Node { field int key; field Node left, right; …
0
votes
1 answer

Regarding the implementation of Power.asm

An Assembly code that does Power: • Implement an Assembly program to calculate the exponential power of a given number n, P(n,e). o For Example. If n = 2 and e = 5 than P(n,e) would be = 22222 = 32. • The user should enter the value of the number n…
user17586998
0
votes
1 answer

Can't run the Nand2Tetris Hardware Simulator

I am trying the Nand2Tetris course, and I got to the point where I want to run and test hdl files with the Hardware Simulator. I downloaded the software suit, followed the instruction below and ran: # I had a dangling symlink issue at the…
0
votes
2 answers

Why is DMux4way operate like this?

When the sel is 01 the b should be chosen, but why the operation is a = nsel1 b = sel[0]? After that the sel will become 00 from 01 CHIP DMux4Way { IN in, sel[2]; OUT a, b, c, d; PARTS: // Put your code here: Not(in = sel[0], out = nsel0); Not(in =…
Xulinow
  • 1
  • 1
0
votes
2 answers

Encounter [0]: sub bus of an internal node may not be used when implementing Not16 with Not

When I was implementing Not16 with Not gates: CHIP Not16 { IN in[16]; OUT out[16]; PARTS: Not(in=[0], out=out[0]); Not(in=[1], out=out[1]); Not(in=[2], out=out[2]); Not(in=[3], out=out[3]); //…
Pandemonium
  • 7,724
  • 3
  • 32
  • 51
0
votes
1 answer

Nand to Tetris how to compile "pop this 2" into asm

I know how to pop a value from the stack to put it in D @SP M=M-1 A=M D=M and I know how to select the memory location "this 2" @2 D=A THIS A=A+D The problem is that I am using D in both steps so obviously just using M=D will not have the desired…
Mathias F
  • 15,906
  • 22
  • 89
  • 159
0
votes
1 answer

Hack assembly: ADD R3,R1,R9, gives the error "expression expected"

I was able to get simple arithmetic operations going using real registers with the assembler, but I saw a code example in the book of ADD R3,R1,R9 and when I try this line by itself as an *.asm file in the Assembler, I get an "expression expected"…
user49404
  • 732
  • 6
  • 22
0
votes
2 answers

How to do bit rotation?

I would like to do bit-rotation in HACK assembly (nand2tetris). For example: 11110000 becomes: 11100001 How will I do this? I saw that normal assembly has the rol syntax that does that but I cant find one for HACK assembly
Belly
  • 33
  • 5
0
votes
1 answer

I am trying to create an 8-bit shift register and not quite sure where I'm going wrong

CHIP Shift8 { IN x; OUT out[8]; PARTS: DFF(x=x, out=d1); DFF(x=d1, out=d2); DFF(x=d2, out=d3); DFF(x=d3, out=d4); DFF(x=d4, out=d5); DFF(x=d5, out=d6); DFF(x=d6, out=d7); DFF(x=d7, out=d8); …
gretta
  • 43
  • 2
0
votes
1 answer

chip Mux4way16 not run ontil the end on ‏HardwareSimulator (VHDL)

I'm tryng to build this chip: // This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name: projects/01/Mux4Way16.hdl /** * 4-way 16-bit multiplexor: * out = a…
Meni
  • 3
  • 1
0
votes
0 answers

Why do I get a "ValueError: I/O operation on closed file" with a file that has not been closed yet?

I am getting the error line 9, in hasMoreCommands if self.asmfile.readline(): ValueError: I/O operation on closed file. This is line 9 from this file: class Parser: def __init__(self, asmfile): try: self.asmfile = open(asmfile,'r') …
0
votes
1 answer

mod(x,y) works for unsigned integers, but not for signed integers in nand2tetris. What changes should I make?

@R2 M=0 @R0 D=M @END D, JEQ @store M=D (LOOP) @R1 D=D-M @REMAINDER D, JLT @EVENLY D, JEQ @LOOP 0, JMP (REMAINDER) @R1 D=D+M @R2 M=D (EVENLY) @store D=M @R0 …
0
votes
1 answer

Subtracting 16-bit 2's compliment numbers in assembly language

I am trying to build a computer chip, similar to the Add16 chip found on nand2tetris, that subtracts 16 rather than adds it. I keep on running into incorrect results however. Can someone help me? Chip Sub16 { IN a[16], b[16]; OUT…
Jimmy Boi
  • 1
  • 2