processor.txt

From Esolang
Jump to navigation Jump to search


processor.txt was made by Miles Poland, on Friday, June 18, 2021. It is inspired by the RISC style of processors, hence the name. The .txt part is because the original specs were written in a .txt file. It is also somewhat of an Esoteric processor.

Instruction set

This is for v1.1

! => Logical NOT of DATA, writes to DATA
& => Logical AND between selected register and DATA, writes to DATA
^ => Logical XOR between selected register and DATA, writes to DATA
, => Copy DATA to a (selects a)
$ => Pops a to DATA (doesn't erase a)
. => Copy DATA to b (selects b)
* => Pops b to DATA (does erase b)
/ => Copy DATA to c (selects c)
? => Pops c to DATA (does erase c)
; => Copy DATA to d (selects d)
: => Pops d to DATA (does erase d)
@ => Copy DATA to e (selects e)
# => Pops e to DATA (does erase e)
[ => Copy DATA to f (selects f)
{ => Pops f to DATA (does erase f)
] => Copy DATA to g (selects g)
} => Pops g to DATA (does erase g)
\ => Copy DATA to h (selects h)
| => Pops h to DATA (does erase h)
> => Moves DATA to the RIGHT
< => Moves DATA to the LEFT
+ => Increment DATA
- => Decrement DATA
~ => Print DATA to STDOUT
( => Target for ')'
) => If DATA is zero, jump to the most recent '('. Otherwise, do nothing.
% => bitshift DATA left
_ => bitshift DATA right, mod 256
` => nop

For a real life implementation of processor.txt, the characters would be replaced with their hex codes, and the hex codes used as opcodes.

Example Programs

Printing my username (has to be run with command line switch "-a"):

++++++++++++++++++++++++++++++++++++++++++++++++++++~++++++++++++++++~----------------~++++~---~-----~

$ clears out data because it copies zeros to where the DATA pointer is. That isn't in 
this program, however, because it isn't needed in this case.

Shorter (and more clever) version:

+%+%%+%%~$+%%%%+%%~$+%+%%+%%~$+%+%+%%%~$+%+%%+%%+~$+%+%%%%~

% is one of the bitshift operators.

Let's translate one of the printing blocks.

+%+%%+%%~$. + means to increment DATA by one. % means 'shift DATA to the left one bit.' ~ means to print DATA. and $ means to set DATA to a. Also, -a means to print out DATA as ASCII. so, the printing block means 'Make the binary number "00110100", print it out as ASCII, than clear DATA.'

Cat program:

Impossible, because processor.txt lacks support for STDIN. [1]

Quine:

I haven't found one yet, feel free to edit one in.

Ok, what is wrong with comments?! And what does DATA mean?

The interpreter only checks the first line for code, which means that other lines are just comments. Hopefully. DATA refers typically to the data under the data pointer, except for > and <, where it refers to the data pointer itself.

Computational Class

In theory, v1.1 would be Turing complete with an infinite data tape. Currently, since v1.1 of the python interpreter is limited to 1KiB of DATA, it isn't turing complete, but in theory could be if DATA dynamically expanded in both directions. However, in its current state, it is just an FSA.

References