Upload
amy-hanlon
View
36
Download
1
Embed Size (px)
Citation preview
Assembly(programming(on(the(nand2tetris(architecture
Amy$Hanlon
@amygdalama
+--------------+ +----------------+| | | | +-----------+| | | | | || | | | <--- | Input || MEMORY | | CPU | | || | <--> | | +-----------+ | | | | +-----------+| | | | | || | | | ---> | Output || | | | | |+--------------+ +----------------+ +-----------+
DATA MEMORY +-------------+ 0 | | | | | RAM | | 16K | | |16383 | | +-------------+ 16384 | | | Screen |24575 | | +-------------+ 24576 | Keyboard | +-------------+
CPU+----------------+| +------------+ || | | || | ALU | || | | || +------------+ || +------------+ || | A register | || +------------+ || +------------+ || | D register | || +------------+ || +------------+ || | control | || +------------+ |+----------------+
Hack%Assembly• A#instruc+ons
@value
@100@foo
Hack%Assembly• C#instruc+ons
dest=comp;jump
D=D-1M=D
// add the numbers stored in the first and second// memory addresses and stores the result in the third
// add the numbers stored in the first and second// memory addresses and stores the result in the third
@0D=M
// add the numbers stored in the first and second// memory addresses and stores the result in the third
@0D=M
@1D=D+M
// add the numbers stored in the first and second// memory addresses and stores the result in the third
@0D=M
@1D=D+M
@2M=D
Links• h#p://www.nand2tetris.org/
Thank&you!