-
Notifications
You must be signed in to change notification settings - Fork 0
/
year36.hrm
102 lines (83 loc) · 2.74 KB
/
year36.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
-- HUMAN RESOURCE MACHINE PROGRAM --
-- 36: Alphabetizer
-- INSTRUCTIONS: "The INBOX contains exactly two words. Determine which
-- word comes first, if you were to order them alphabetically, and send
-- only that word to the OUTBOX."
-- AVAILABLE COMMANDS: INBOX, OUTBOX, COPYFROM, COPYTO, ADD, SUB,
-- BUMPUP, BUMPDN, JUMP, JUMPZ, JUMPN, COMMENT
-- SIZE: 30 commands (challenge 39)
-- AVERAGE RUNTIME: 71 steps (challenge 109)
-- Tile 21: Character currently being compared
-- Tile 22: Pointer into first string
-- Tile 23: Permanent zero
-- Tile 24: Permanent ten, for some reason
COPYFROM 23
COPYTO 22
a:
-- Copy first word to the floor.
INBOX
COPYTO [22]
JUMPZ b
BUMPUP 22
JUMP a
b:
COPYTO 22
JUMP d
c:
-- If the words share a prefix, copy it to the outbox.
COPYFROM 21
OUTBOX
BUMPUP 22
d:
-- Compare the second word to the first word one value at a time.
INBOX
JUMPZ h
COPYTO 21
COPYFROM [22]
JUMPZ i
SUB 21
JUMPN f
JUMPZ c
COPYFROM 21
e:
-- If the second word lexicographically precedes the first word, copy
-- the rest of it to the outbox immediately.
OUTBOX
INBOX
JUMPZ j
JUMP e
f:
g:
-- If the first word lexicographically precedes the second word, copy
-- the rest of it to the outbox immediately.
COPYFROM [22]
JUMPZ k
OUTBOX
BUMPUP 22
JUMP g
h:
i:
j:
k:
DEFINE LABEL 21
eJzTZmBgYE34nu4e/zklPHJFzOOQzNiP/p9Tar05Spo8b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