pyhton (sic)

From Esolang
Jump to navigation Jump to search
The title of this article is not correct because of technical limitations. The correct title is actually pyhton [sic].

pyhton [sic] is an esoteric programming language created by Something Fawful. It is technically the second language he has created, but the interpreter for Pyhton [sic] has been easier to get working, and is somewhat easier to explain so it is being uploaded first. The language's name is an intentional typo of Python, including a [sic] afterwords, so that if you are quoting someone who spelled Python as Pyhton, it will be impossible to tell if it is referring to Pyhton [sic] or Python. pyhton [sic]'s name should be in lower case at the start of a sentence, and with an uppercase p otherwise.

Usage

pyhton [sic] operates on a base 7 machine, with a 7 septit register. Upon running a Pyhton [sic] program, the program is loaded into memory, and execution begins at the start. The following are the operations in Pyhton [sic]

Code Op Name Description
0 NOP No operation, your standard NOP command.
1 ATA AcTion A. Adjust the value of the register given in the next Septit of the program, it will convert a register according to the following table:
Input Output
0 3
1 1
2 2
3 6
4 5
5 6
6 0
2 ATB AcTion B. Adjust the value of the register given in the next Septit of the program, it will convert a register according to the following table:
Input Output
0 2
1 3
2 6
3 5
4 1
5 0
6 4
3 ATC AcTion C. Adjust the value of the register given in the next Septit of the program, it will convert a register according to the following table:
Input Output
0 6
1 2
2 3
3 1
4 5
5 0
6 4
40 RDI ReaD Input. Reads 7 septits of input into the register. What exactly the input is can be implementation dependent, as it is not part of the spec. In the standard implementation, it reads an integer from Standard Input, and converts it into 7 septits, ignoring any extra, with the 6th septit being the least significant.
41 WRT WRiTe. Writes the content of the 7 septits to memory, with the zeroth septit in the register being at the location given after the 41. The index value of where to write is absolute, and dependant on the length of the program. Should the value be above the length of the program, it will expand the program, padded with 0s, but will not increase the program's index size. For example if the current index size is 3 (so the program is less than 343 Septits long), 41665 will increase the programs size to be exactly 343 septits long, but no more.
42 OUT OUTput. Outputs the values stored at the beginning of the program. How exactly it is output can be implementation dependent, is it is not part of the spec. In the standard implementation, it is converted 3 septits to a Unicode character between 0 and 343, which is output to Standard Output. How many septits it will output is dependent on the value set by the AOS command, and using OUT before AOS will crash in a compliant implementation.
43 PLP PLoP. Increases the size of the program by 1 septit. Unlike WRT, PLP Will increase the size of the index if necessary. This allows for infinite memory in a fully complaint implementation.
44 AOS Adjust Output Size. Adjusts the amount of the start of the program that will be output. Uses the values in the register, with the 0th septit being the most significant.
45 END END program. Using END is the only way to correctly end a program. Should a compliant implementation reach the end of memory without encountering END it should crash.
46 RNR RuN Register. Runs through the register as if it was the next 7 Septits of the program. This is currently untested and glitchy in the official implementation.
5 SLP SLeeP. Similar to the SLP opcode in 65c816 Assembly. Causes the program to permanently enter an infinite loop.
6 JMP JuMP. Unconditional Jump to the specified location. As with WRT the address is absolute and size of address depends on the length of the program.

Naturally, a program isn't written using only 0-6, that would take far too much space, a standard 8-bit character can easily contain 2 septits, or 49 distinct values. the characters that represent each value are listed below.

raw character value
]
00
#
01
+
02
^
03
;
04
{
05
:
06
)
10
<
11
,
12
6
13
	
(a tab character)
14
h
15
'
16
(
20
5
21
>
22
@
23
0
24
?
25
I
26
9
30
3
31
1
32
/
33
7
34
.
35
 
(a space character)
36
i
40
l
41
|
42
!
43
~
44
8
45
-
46
=
50
$
51
[
52
4
53
&
54
}
55
`
56
_
60
*
61
"
62
\
63
2
64
%
65
[a unix style newline]
66

Any other characters, including the carriage return of the Windows style linefeed will crash.

Sample Programs

Hello World

The following program prints "Hello World" in the standard implementation.

6>^5165_~h1'>>6(I()5<11'h?~|8

The following program prints "Hello World!" in the standard implementation.

_$^5165_~h1'>>6((8' h?~)9<>@.h l];0=

Truth-Machine

The following truth-machine takes inputs that are not multiples of seven as 1 and multiples as seven as zero. This makes 1 and 0 behave as expected, naturally. Making behaviour undefined for input other than 1 or 0 would have been much simpler, but I only thought of that after finishing the program.

i)))()(9)9))9(())<<<5<53<3<<355<<,,,>,>1,1,,1>>,,666@6@/6/66/@@66			0	07	7		700		hhh?h?.h.hh.??h' ''I ''I '' I l!={#["2!60)]|8]]]]]]]]]]]]]]hI'~99(l];I_=

Short Truth-Machine

This truth-machine will have undefined behavior for inputs other than 1 or 0. However, it is much shorter, with an index size of only 2.

'~i.'Il	]]#^;);Il^60);0=

External resources