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
1
vote
1 answer

Confusion related to virtual machine in nand2tetris

So while doing a course on nand2tetris I got stuck in this question. Basically this question is related to building a virtual machine. The virtual machine is quite similar to JVM.
Anshul Gupta
  • 265
  • 2
  • 12
1
vote
2 answers

Example of Clock and DFF for Nand2Tetris Hack .asm Assembly Code

I am a huge learn-by-example person, which means describing it is typical leaves me at a loss, for my learning style, because I need to see first, and then any explanation can be realized. I have been playing with the Nand2Tetris program's Hack…
A Nichole
  • 13
  • 3
1
vote
1 answer

Is there a way regex will match all the combinations of the tokens in `|` operator

I am doing a parser for nand2tetris project. I want to check if the destination field is either M|D|MD|A|AM|AD|AMD and their different ways of combinations like MA not only AM. ^(M|D|MD|A|AM|AD|AMD)\s*=$ This regex correctly matches AM=, but not…
Henok Tesfaye
  • 8,287
  • 13
  • 47
  • 84
1
vote
1 answer

Comparison error when implementing a MUX gate in nand2tetris

I am trying to implement a MUX (Multiplexor) gate in the nand2tetris course. I first tried myself, and I got an error. But no matter what I changed I always got the error. So I tried checking some code online, and this is what most people use: CHIP…
S1LV3R
  • 146
  • 3
  • 15
1
vote
2 answers

In line 0, Expression expected Error (Nand2tetris CPU-emulator)

This is not a duplicate of this one, as I don't have any syntax error -- I only got two lines of code, so I am certain! Note: I did remember to save BasicLoop.asm before attempting to load it. I can change the .asm code to whatever I like, the…
xing Zì
  • 391
  • 4
  • 16
1
vote
1 answer

nand2tetris. Memory implementation

I realized Data memory implementation in nand2tetris course. But I really don't understand some parts of my implementation: CHIP Memory { IN in[16], load, address[15]; OUT out[16]; PARTS: DMux4Way(in=load, sel=address[13..14],…
helsereet
  • 111
  • 1
  • 5
1
vote
2 answers

DMux.hdl failure when in=1, sel=0

I'm writing the hdl code for a DMux based on the Nand2Tetris course. CHIP DMux { IN in, sel; OUT a, b; PARTS: And(a = sel, b = in, out = b); Not(in = sel, out = selNot); And(a = in, b = selNot, out = a); } For some reason, this code fails on…
yalpsid eman
  • 3,064
  • 6
  • 45
  • 71
1
vote
2 answers

regex to catch assembler C-command

I'm taking the Nand-2-Tetris course. We are asked to write and assembler. A C-command is in the type of dest=comp;jump where each part is optional. I was trying to write a regex to make everything easier - I want to be able to compile the expression…
Dvir Itzko
  • 404
  • 4
  • 17
1
vote
1 answer

Can't find my mistake in the implementation of the counter

I'm implementing the counter from chap. 3. Here is my code: // 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/03/a/PC.hdl /** * A…
Planet_Earth
  • 325
  • 1
  • 3
  • 11
1
vote
1 answer

In HDL file ///.hdl Line , Can't connect part's output pin to gate's input pin: load .hdl

SPOILER ALERT: Contains a brief code snippet from Memory.hdl (project 5). I am receiving the error listed in the title of this question, yet I am certain that it is not related to connecting an internal part's output pin to the chip's input…
Kayce Basques
  • 23,849
  • 11
  • 86
  • 120
1
vote
2 answers

why does a full adder take in 3 numbers and not 2

So I was asked a question in uni and after a having a look I really couldn't find an answer. Why does a full adder takes in 3 number and not 2. Is it so that it can retain the carry from the 1st half adder? Thanks.
Safwan Ull Karim
  • 652
  • 5
  • 10
  • 20
1
vote
3 answers

How to increment integers on the current line by 1

I'm working on nand2tetris, and I end up with a lot of files that end up looking like this: Bit(in=in[0], load=load, out=out[0]); Bit(in=in[1], load=load, out=out]1]); ... Bit(in=in[15], load=load, out=out[15]); So I've been yanking the first line,…
charmeleon
  • 2,693
  • 1
  • 20
  • 35
0
votes
1 answer

Nand2Tetris: How to code 16-bit constant in ALU

I'm doing ALU task in Project 2 in Nand2Tetris course. // and operates on the resulting values, as follows: // if (zx == 1) set x = 0 // 16-bit constant // if (nx == 1) set x = !x // bitwise not // if (zy == 1) set y = 0 //…
0
votes
1 answer

how to debug the Expected ), Expected { and Expected statement(do, let, while, return or if) errors in jack Programming Language

I am working on Jack's programming language and trying to make a hangman game code I have written the code for the game without graphical representation. but I can't find any help for debugging my code so far is class HangmanGame { field String…
0
votes
2 answers

Racket lexer greedy selection

I am trying to write lexer with racket , and I am using parser-tools/lex and parser-tools/lex-sre. and I would like to create Token for strings - but Because the lexer selection is not greedy if I have : "this is" .... "cool" it will be one token…
IDANG
  • 11
  • 2