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
19
votes
5 answers

How do I set output flags for ALU in "Nand to Tetris" course?

Although I tagged this homework, it is actually for a course which I am doing on my own for free. Anyway, the course is called "From Nand to Tetris" and I'm hoping someone here has seen or taken the course so I can get some help. I am at the stage…
MahlerFive
  • 5,159
  • 5
  • 30
  • 40
16
votes
2 answers

How can I write an interpreter for 'eq' for Hack Assembly language?

I am reading and studying The Elements of Computing Systems but I am stuck at one point. Sample chapter skip the next 5 instruction s can be found here. Anyway, I am trying to implement a Virtual Machine (or a byte code to assembly translator) but…
Koray Tugay
  • 22,894
  • 45
  • 188
  • 319
11
votes
2 answers

What's wrong with my DMux 4 way?

It's seemingly close to working, it just is messing up at line 7 apparently? /** * 4-way demultiplexor. * {a,b,c,d} = {in,0,0,0} if sel==00 * {0,in,0,0} if sel==01 * {0,0,in,0} if sel==10 * {0,0,0,in} if…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
9
votes
1 answer

Dealing with arrays in HDL

How does one use arrays (representing busses) in HDL? For example, I have the following code: /** * 16-bit bitwise And: * for i = 0..15: out[i] = (a[i] and b[i]) */ CHIP And16 { IN a[16], b[16]; OUT out[16]; PARTS: // Put your…
Fine Man
  • 455
  • 4
  • 17
6
votes
7 answers

implement eq, lt gt in assembly without jumps

Is it possible to write logic using only the AND, OR, and NOT operators to compare 2 operands and return true/false (-1, 0) without the use of jumps? If so, can you please give me some hints as it looks impossible to me. I am trying to implement eq,…
culchie
  • 73
  • 1
  • 6
5
votes
2 answers

logic gate XOR HDL not working with Nand2Tetris

i'm not too sure why my Nand2tetris simulator keep telling me line 3 error. can anyone tell me any problem with the following code: CHIP Xor { IN a, b; OUT out; PARTS: Not(in=a, out=nota); Not(in=b, out=notb); And(a=a,…
5
votes
3 answers

Trying to build a PC (counter) for the nand2tetris book, but I'm having some trouble with the logic

Here's my code: CHIP PC { IN in[16],load,inc,reset; OUT out[16]; PARTS: Inc16(in = regout, out = incout); Mux16(a = regout, b = incout, sel = inc, out = incdecision); Mux16(a = incdecision, b = false, sel = reset, out =…
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
4
votes
3 answers

Error "Out of segment space" in VMEmulator cause by a getter mwthod in Jack

I am doing a project for nand2tetris. We write a program in Jack and test it on VMEmulator. The class looks like this: class List { field int data; field List next; /* Creates a new List object. */ constructor List new(int car, List…
Alex Ding
  • 41
  • 4
4
votes
2 answers

nand 2 tetris ASM "Expression Expected"

I am currently trying to finish off the project found in Chapter 4 of the Nand to Tetris course (Fill.asm). However, Assembler is giving me the following error: "In line 3, Expression Expected" I'm not sure what I'm doing wrong... but below is the…
user1867675
  • 49
  • 1
  • 3
3
votes
1 answer

Trying to build a PC (counter) for the nand2tetris , but I'm having some trouble with the logic

The project aims to build a program counter. The description are as follows: // This file is part of www.nand2tetris.org // and the book "The Elements of Computing Systems" // by Nisan and Schocken, MIT Press. // File name:…
3
votes
2 answers

Why does my code keep get a comparison failure at line 2, and how could I fix this?

In hack assembly language in the CPU simulator Add4.asm, the test keeps failing at line 2. I have tried various forms to fix it but can't figure it out. How can I set it to 0 or if that's not the issue, how else could I fix my code? ADD4 Hack…
3
votes
1 answer

Why doesn't this minimal Jack (nand2tetris) program compile?

I'm using a language called Jack, as part of the Nand2Tetris course. This compiles and produces the output I expect when run: class Main { function void main() { var Foo f; do f.doSomething(); return; } } class Foo…
2
votes
1 answer

Would it be possible to write a HACK assembler in JACK?

I'm working on the nand2tetris course right now, and I'm currently writing the assembler in Lua. I know that later down the line we will be writing a JACK compiler. After I'm done with the course, and I have a HACK computer with an OS and virtual…
username
  • 25
  • 3
2
votes
2 answers

VMEmulator Nand2Tetris

I am currently working through Project 7 on Nand2Tetris, and when the VM Emulator loads the .asm file, I am faced with the error: SimpleAdd.asm: in line 1: unknown instruction - @SP I thought SP was a predefined symbol that points to the stack…
Mat
  • 21
  • 1
2
votes
1 answer

Understanding Hack Assembly Language code

My teacher gave me this example code to learn from, I still don't understand it, to do with Assembly language code & nand2tetris. Can someone explain? Update: (I posted the entire code instead) // PSEUDO CODE // x=R1 // y=R2 // R3=0 …
user17364008
1
2 3 4 5 6 7 8