-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputeDiv.tst
More file actions
66 lines (49 loc) · 1.15 KB
/
ComputeDiv.tst
File metadata and controls
66 lines (49 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
load Computer.hdl,
output-file ComputerDiv.out,
compare-to ComputerDiv.cmp,
output-list time%S1.4.1 reset%B2.1.2 ARegister[]%D1.7.1 DRegister[]%D1.7.1 PC[]%D0.4.0 RAM16K[0]%D1.7.1 RAM16K[1]%D1.7.1 RAM16K[2]%D1.7.1;
// Load a program written in the Hack machine language.
// The program computes the division of RAM[0] and RAM[1]
// and writes the result in RAM[2].
ROM32K load Div.hack,
// first run: compute div(1,1)
set RAM16K[0] 1,
set RAM16K[1] 1,
output;
repeat 20 {
tick, tock, output;
}
// reset the PC
set reset 1,
tick, tock, output;
// second run: compute div(9,3)
set reset 0,
set RAM16K[0] 9,
set RAM16K[1] 3,
output;
repeat 50 {
tick, tock, output;
}
set reset 1,
tick, tock, output;
// compute div(0,6)
set reset 0,
set RAM16K[0] 0,
set RAM16K[1] 6,
output;
repeat 50 {
tick, tock, output;
}
set reset 1,
tick, tock, output;
// compute div(8,4)
set reset 0,
set RAM16K[0] 8,
set RAM16K[1] 4,
output;
repeat 50 {
tick, tock, output;
}