teaching machines

CS 352 Lecture 15 – Hack Assembly

October 10, 2016 by . Filed under cs352, fall 2016, lectures.

Dear students,

Now that we have all the fundamental hardware components for our computer, let’s rise another layer of abstraction. We will discuss the machine code and assembly code, which are really just encodings of the inputs that will be fed to our hardware components.

The Nand2Tetris computer has the following architecture:

Today we’ll explore this architecture by writing some Hack assembly programs:

Here’s your TODO list to complete before we meet next:

See you next class!

Sincerely,

P.S. Here’s the code we wrote together:

SumR.asm

@R0
D=0
D=D+M
@R1
D=D+M
@R2
M=D

Ord.asm

@KBD
D=M

@65
D=D-A

@ORD
M=D

Even.asm

D=1

@R0
M=M+1
D=D&M

@ISEVEN
M=D