Rosa Parks

Rosa Parks is a language by Plokmijnuhby (talk), based around bus conflicts and race conditions.
== Overview ==
All calculation in the language is done by devices. The syntax consists of
 <device><targets>
Each device has an internal value, initialised to 0 (apart from literals, see below).
At each timestep, each device sends its value as a signal to its targets along the relevant buses, and then sets its own value to the value of an incoming signal.
If multiple devices send a signal to the same device simultaneously, we have a bus conflict: the device's new value is instead the bitwise OR of all incoming signals.
If devices do not recieve a signal, they set their value to 0.
Devices may have themselves as a target (sometimes useful for literals).
If a device is given targets more than once, the different targets are all attached to the device, so
 device first
 something something
 device second
is equivalent to
 device first second
 something something
However, giving the same device the same target twice is an error (the only error in the language).
Calculation ends when all devices retain the same value and INPUT does not trigger during one timestep.
== Special devices ==
* INPUT: after every timestep, takes an ascii char of input if it has a non-zero value. It then converts that char to a byte and sets the result as its value.
* OUTPUT: after every timestep, if its value is printable ascii, it prints it. OUTPUT precedes INPUT.
* MEM and MEMADDR: MEM gives its value as the value in address MEMADDR. It then sets the value in address MEMADDR to the value of an incoming signal.
* SHIFTL and SHIFTR: performs bitshift left or right respectively on their value between timesteps. Equivalent to integer divide/multiply by 2.
* BOOL: sets every bit in its value to 1 if any bit in its value is 1.
0,1,2,3... : These devices target each other. 1 targets 0, 2 targets 1, etc. 0 has no default target. They may be given additional targets.
A set of devices like this is called a daisy chain.
This also works for anything suffixed with a number: list90 and list:90 are both part of valid daisy chains.
Literals: these have their value initialised to an unusual value.
Literals may be single ascii characters in quotes, or numbers prefixed with \b,\o,\d or \x for different bases.
Devices prefixed with ~ will perform bitwise NOT on their value between timesteps. As every number is a bignum, this turns x into -x-1 using 2's complement.
== Examples ==
=== Hello World ===
Demonstrates how daisy chains form a delay line.
 "H" 0
 "e" 1
 "l" 2 3 9
 "o" 4 7
 " " 5
 "W" 6
 "r" 8
 "d" 10
 "!" 11
 0 OUTPUT
=== Cat ===
EOF is 0, which prevents INPUT from triggering.
 \b1 INPUT
 INPUT OUTPUT INPUT
=== Truth test ===
Shows how to defeat the loop detector by toggling values. Also provides an example of a bus conflict.
 "0" 0 1 INPUT
 0 1
 INPUT OUTPUT 1
 OUTPUT OUTPUT
=== Addition ===
Adds two bytes. May be adjusted for any number of bits. Shows how to use multiple daisy chains.
 \x23 A ~A 
 \x5A B ~B
 
 A ~(Aor~B)
 ~A ~(Bor~A) ~(~Aor~B)
 B ~(Bor~A)
 ~B ~(Aor~B) ~(~Aor~B)
 
 ~(Aor~B) AxorB ~output
 ~(Bor~A) AxorB ~output
 ~(~Aor~B) SHIFTL
 
 AxorB A ~A
 SHIFTL B ~B
 
 
 ~ flush:23
 flush:0 ~(AorB) ~(Bor~A) ~(~Aor~B)
 \xFF 22
 0 ~end
 ~end ~output
 ~output OUTPUT
Category:Languages