-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathto-uppercase.txt
61 lines (59 loc) · 7.58 KB
/
to-uppercase.txt
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
to-uppercase
━━━━━━━━━━━━
• Convert lowercase ascii characters to uppercase.
• Other ascii characters are left untouched.
• Data is read from stdin and written to stdout.
• Every byte take a single cycle of 312 ticks to be processed.
╔══════════════════════════════════════════════════╗
║ ╔════════════════════════════════════════════╗ ║
║ ║ ╔══════════════════════════════════════╗ ║ ║
║ ║ ║ ╔════════════════════════════════╗ ║ ║ ║
║ ║ ║ ║ ╔══════════════════════════╗ ║ ║ ║ ║
║ ║ ║ ║ ║ ╔════════════════════╗ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ╔══════════════╗ ║ ║ ║ ║ ║ ║ ┓ 8 marbles representing a byte
║ ║ ║ ║ ║ ║ ║ ╔════════○ ○ ○ ○ ○ ○ ○ ○ ┛ This is the main variable
╓○ ╓○ ╓○ ╓○ ╓○ ╓○ ╓○ ╓○ ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗ ┓
║ ║ ║ ║ ║ ║ ║ ║ ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝ ┃
║ ║ ║ ║ ║ ║ ║ ║ ○══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╗ ┃ Synchronization
║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗║ ┃ The right-most marble exits first
║ ║ ║ ║ ║ ║ ║ ║ ║ ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝║ ┃
║ ║ ║ ║ ║ ║ ║ ║ ╚══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╝ ┛
║ ║ ║ ║ ║ ║ ║ ║ ╙○ ╙○ ╙○ ╙○ ╙○ ╙○ ╙○ ╙○ ┓ Read a byte from stdin
║ ║ ║ ║ ║ ║ ║ ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ LSB is on the right
║ ║ ║ ║ ║ ║ ║ ║ ╙◇ ╙◇ ╙◇ ╙◇ ╙◇ ╙◇ ╙◇ ╙◇ ┛
║ ║ ║ ║ ║ ║ ║ ║ ╚━╗╚═╗╚═╗║ ║ ║ ║ ║ ┓ Detect bytes in the range [0x60, 0x7f]
║ ║ ║ ║ ║ ║ ║ ║ ○ ╔╤╝╔╤╝╔╤╝║ ║ ║ ║ ║ ┃ It includes all lowercase letters ([0x61, 0x7a])
║ ║ ║ ║ ║ ║ ║ ║ ╔══○╛━╬╛═╬╛═╬╛═╬══╬══╬══╬══╬══╗ ┛
║ ║ ║ ║ ║ ║ ║ ║ ║ ┃ ║ ║ ╚═╗╚═╗╚═╗║ ║ ╚═╗ ┓
║ ║ ║ ║ ║ ║ ║ ║ ║ ○ ║ ║ ║ ╔╤╝╔╤╝╔╤╝║ ║ ╔╒╝ ┃ Exclude bytes 0x7c, 0x7d, 0x7e and 0x7f
║ ║ ║ ║ ║ ║ ║ ║ ║ ○╛━╬══╬══╬══╬╛═╬╛═╬╛═╬══╬═━╬╧═╗ ┃ This corresponds to '|', '}', '~' and 'DEL'
║ ║ ║ ║ ║ ║ ║ ║ ║ ╚══╬══╬══╬══╬══╬══╬══╬══╬══╬══╝ ┛
║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗╚═╗╚━╗╚═╗╚═╗╚═╗ ┓
║ ║ ║ ║ ║ ║ ║ ║ ║ ○ ║ ║ ║ ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╒╝ ┃ Exclude byte 0x7b
║ ║ ║ ║ ║ ║ ║ ║ ║ ○╛━╬══╬══╬══╬╛═╬╛═╬╛═╬╛═╬╛━╬╧═╗ ┃ This corresponds to '{'
║ ║ ║ ║ ║ ║ ║ ║ ║ ╚══╬══╬══╬══╬══╬══╬══╬══╬══╬══╝ ┛
║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚━╗╚━╗╚═╗╚━╗╚━╗╚═╗ ┓
║ ║ ║ ║ ║ ║ ║ ║ ║ ○ ║ ║ ║ ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╒╝ ┃ Exclude byte 0x60
║ ║ ║ ║ ║ ║ ║ ║ ║ ○╛━╬══╬══╬══╬╛═╬╛═╬╛═╬╛═╬╛━╬╧═╗ ┃ This corresponds to '`'
║ ║ ║ ║ ║ ║ ║ ║ ║ ╚══╬══╬══╬══╬══╬══╬══╬══╬══╬══╝ ┛
║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗┃ ┃ ┃ ┃ ┃ ║ ┓ Clear bit 6 if the byte is a lower case letter
║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ║ ╔╒╝║ ║ ║ ║ ║ ║ ┃ This effectively maps the letter to its uppercase version
║ ║ ║ ║ ║ ║ ║ ║ ╚═════╬══╬══╬╧━╬══╬══╬══╬══╬══╝ ┛
║ ║ ║ ║ ║ ║ ║ ║ ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗ ┓
║ ║ ║ ║ ║ ║ ║ ║ ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝ ┃
║ ║ ║ ║ ║ ║ ║ ║ ○══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╗ ┃ Synchronization
║ ║ ║ ║ ║ ║ ║ ║ ║ ╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗╚═╗║ ┃ The right-most marble exits first
║ ║ ║ ║ ║ ║ ║ ║ ║ ╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝╔╤╝║ ┃
║ ║ ║ ║ ║ ║ ║ ║ ╚══╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╬╛═╝ ┛
║ ║ ║ ║ ║ ║ ║ ║ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ╟◆ ┓
║ ║ ║ ║ ║ ║ ║ ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ Write the byte to stdout
║ ║ ║ ║ ║ ║ ║ ║ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ╟◇ ┃ LSB is on the right
║ ║ ║ ║ ║ ║ ║ ║ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┃ ┛
║ ║ ║ ║ ║ ║ ║ ╚════════╝ ║ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ║ ╚══════════════╝ ║ ║ ║ ║ ║ ║
║ ║ ║ ║ ║ ╚════════════════════╝ ║ ║ ║ ║ ║
║ ║ ║ ║ ╚══════════════════════════╝ ║ ║ ║ ║
║ ║ ║ ╚════════════════════════════════╝ ║ ║ ║
║ ║ ╚══════════════════════════════════════╝ ║ ║
║ ╚════════════════════════════════════════════╝ ║
╚══════════════════════════════════════════════════╝