mirror of
https://github.com/captn3m0/nand2tetris.git
synced 2024-09-28 04:23:29 +00:00
36 lines
277 B
NASM
36 lines
277 B
NASM
|
@i
|
||
|
M=1
|
||
|
|
||
|
@sum
|
||
|
M=0
|
||
|
|
||
|
(LOOP)
|
||
|
|
||
|
@i
|
||
|
D=M
|
||
|
@10
|
||
|
D=D-A
|
||
|
@END // refers to the instruction memory location for END label and puts that in A
|
||
|
D;JGT
|
||
|
@i
|
||
|
D=M
|
||
|
|
||
|
@sum
|
||
|
M=D+M
|
||
|
|
||
|
@i
|
||
|
M=M+1
|
||
|
@LOOP // Put the instruction memory location for LOOP in A
|
||
|
0;JMP // Jump to A
|
||
|
|
||
|
(END)
|
||
|
|
||
|
@sum
|
||
|
D=M
|
||
|
|
||
|
@R0
|
||
|
M=D
|
||
|
|
||
|
@END
|
||
|
0;JMP
|