The Benedict Year › The workshop

Project 6 · Weeks 31–33

The assembler

The translator from the language people write to the ones and zeros the machine runs. Done by hand, it is a code to break, like the Morse of Unit 2.

Beside Unit 11 · Law

In the course: Project 6, Assembler · slides and project notes at nand2tetris.org

The kind of answer

Enacted. The instruction set is a law the machine keeps from without, never from within. The assembler applies the code exactly as it is written, line by line, as a rule is applied.

On paper first

Turn @17 into sixteen bits. Then turn D=M+1 into sixteen bits with the course’s tables. Check both with the Assembler.

What you build

In the Assembler. The files for Project 6 are in the IDE’s own projects folder, so there is nothing to download.

  • Add.asm, translated by hand
  • Max.asm, translated by hand
  • Rect.asm, translated by hand

Each one is done when its test passes in the IDE. A pass cannot be argued with, and neither can a fail.

Week by week

About an afternoon a week. If a week runs long, let it: the strand keeps its own order, not the calendar’s.

WeekWatchDo
Week 316.1; 6.2; 6.3What an assembler is, and how each kind of instruction is translated. Translate Add.asm by hand and check it against the Assembler in the IDE.
Week 326.4; 6.6BSymbols: labels and variables. Translate Max.asm by hand, finding the labels first and then everything else, as the lecture does.
Week 336.5; 6.6; 6.7Rect.asm by hand. Lectures 6.5 and 6.6 show how to write an assembler as a program; that is for a second year, so watch them as a look ahead.

The lectures

8 lectures, about 123 minutes in all, by Nisan and Schocken. Watch with your parent, one or two at a sitting.

For the parent

The course lets the assembler be written as a program or done by hand, and lecture 6.6B covers the by-hand way. A child who knows Scratch can build a small assembler there, with lists for the course’s tables, but it is not needed. Writing it in a real programming language is for a second year.

Public domain I have dedicated this page to the public domain under CC0 1.0. Copy it, change it, translate it, print it and share it, for any purpose, without asking. Quotations from other writers keep their own terms.