-
Notifications
You must be signed in to change notification settings - Fork 0
/
year20-fast.hrm
143 lines (124 loc) · 3.43 KB
/
year20-fast.hrm
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
-- HUMAN RESOURCE MACHINE PROGRAM --
-- 20: Multiplication Workshop
-- INSTRUCTIONS: "For each two things in the INBOX, multiply them, and
-- OUTBOX the result. Don't worry about negative numbers for now."
-- AVAILABLE COMMANDS: INBOX, OUTBOX, COPYFROM, COPYTO, ADD, SUB,
-- BUMPUP, BUMPDN, JUMP, JUMPZ, JUMPN, COMMENT
-- SIZE: 64 commands (challenge 15)
-- AVERAGE RUNTIME: 86 steps (challenge 109)
-- Tile 0: Larger value
-- Tile 1: Partial sum
-- Tile 2: Smaller value
-- Tile 9: Permanent zero
-- Given a pair of items, place a zero in the outbox if either item has
-- a value of zero. Otherwise, maintain a partial sum by repeatedly
-- adding the larger value, using the smaller value as a counter. After
-- performing the correct number of additions, place the sum in the
-- outbox.
-- The first two items are always nonzero.
INBOX
COPYTO 0
COPYTO 1
INBOX
COPYTO 2
SUB 0
JUMPN b
COPYFROM 2
a:
COPYTO 1
BUMPDN 0
JUMPZ e
COPYFROM 1
ADD 2
JUMP a
b:
c:
BUMPDN 2
JUMPZ d
COPYFROM 1
ADD 0
COPYTO 1
JUMP c
d:
e:
COPYFROM 1
OUTBOX
-- The third and fourth items are always nonzero.
INBOX
COPYTO 0
COPYTO 1
INBOX
COPYTO 2
SUB 0
JUMPN g
COPYFROM 2
f:
COPYTO 1
BUMPDN 0
JUMPZ k
COPYFROM 1
ADD 2
JUMP f
g:
h:
i:
BUMPDN 2
JUMPZ j
COPYFROM 1
ADD 0
COPYTO 1
JUMP i
j:
k:
l:
COPYFROM 1
OUTBOX
-- The sixth item is always zero, so throw away the fifth item.
INBOX
INBOX
OUTBOX
-- The seventh item is always zero, so throw away the eighth item.
INBOX
OUTBOX
INBOX
-- The ninth and tenth items are always nonzero.
INBOX
COPYTO 0
COPYTO 1
INBOX
COPYTO 2
SUB 0
-- Reuse earlier commands to reduce program size.
JUMPN h
COPYFROM 2
m:
COPYTO 1
BUMPDN 0
-- Reuse earlier commands to reduce program size.
JUMPZ l
COPYFROM 1
ADD 2
JUMP m
DEFINE LABEL 0
eJyTYmBgYE34k8WUmBpVlzQ72DxV0GdDureHeCGHm1t5RGBD5fNouyq1zurqndM21UWs1Wx6vCW5RW37
xa7MnQcn3NtoMSVkVdE0jkUfpjXNBRrFwDxhi3l73w6rNw0H89zKtXoiCwKWG6WbH2YYJKC7dOc0EJ3d
uDf7ff38lvX1P6aC+KnNhabLm75bgthF0+xzf0z+k+Xab50l0M1TfqXzXrNw15bJAt17Z3r0HZ1fNZll
Pkjd4eXnyrmWepfNnH+pKn5uTFPinBVdSnM+T1o4Z+c02XkH51xd4L7QZwnLfNblZlMbV9xrtln1edLm
tUfBehdsOThnwZbnnU83Ta5O2+RcABJL2DK5WmyHe7HgLpZCzr1HC/cf8C77c1Cywe7glsm1B+tmgdRs
vuNezHydIa/9qn2u15WDeUEXvcvCz89uvHlOrfPmudy+6eeNJl28+GOq1xXrGVa39s4E6dl2+73x5zsM
eUZ3IXE0CkYBMgAATsqmEA;
DEFINE LABEL 1
eJyTYGBgONNz0k2gu8nxedMfm6PlBx1k8s96Ps2+F/oiSysuJccsXT5vb/bUQueC6ur+iuSWkJrQztmN
57ozu8/07J0Z0M279FpHxNrYtnsb3zSobf9TlbkzsPjxlrl5t9atyApYzjCEQUG9+0KWipOLQOySqYJy
5VOsbbZN6Sq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