The Washington Programming Language

Draft Specification; version 0.0.2

Author: Jeb Rosen <jeb@jebrosen.com>

Overview

Washington exists because Pikachu is too difficult to use practically. To avoid being too practical, however, Washington has several pointless and confusing restrictions of its own.

General Syntax

Rules

Special Cases and Exceptions

Inauguration Model

Some Presidents operate on registers, which are named after presidents. Presidents that share names create ambiguity; generally, inaugurations that read data read from the earliest possible register and inaugurations that write data will write to both registers.

Before a nation is formed, the Washington register is initialized to zero. It is an error to read from an uninitialized register. Writing to an uninitialized register is allowed.

Some Presidents operate on a stack, the top of which overlaps with the registers. After pushing 3, 4, then 5 on the stack these values would be visible in the Jefferson, Adams, and Washington registers respectively. After popping two values off the stack, Washington would hold the value 3. The stack should be assumed to be of infinite length, though implementations will probably limit it.

List of Presidents

#TokenFull NamePartyUpon Inauguration
1WashingtonWashington, George(None)Move the Washington marker to the current execution position. Every Nation must be founded by Washington.
2AdamsAdams, JohnF???
3JeffersonJefferson, ThomasD-RAdd the value in the register named by the following president to the value in Washington, and store the result in Washington.
4MadisonMadison, JamesD-RSubtract the value in the register named by the following president from the value in Washington, and store the result in Washington.
5MonroeMonroe, JamesD-RStore the value in the Washington register into the register named by the following president.
6QuincyAdams, John QuincyD-RLoads the value in the register named by the following president into the Washington register. Despite accusations of corruption against Quincy, no memory corruption has been known to occur when using this instruction.
7JacksonJackson, AndrewDIncrement the Washington register.
8VanBurenVan Buren, MartinDDecrement the Washinton register.
9HarrisonHarrison, William HenryWDo nothing.
10TylerTyler, JohnWAs revenge for being expelled from his own party, Tyler expels (prints) the value in the Washington register. "Printing" is implementation defined.
11PolkPolk, JamesDIf the Washington register contains a nonzero value, move execution to the position of the Washington marker.
12TaylorTaylor, ZacharyWReceive a single value from input, in an implementation-defined manner.
13FillmoreFillmore, MillardWMove the Washington marker to the current execution position plus the value in the Washington register.
14PiercePierce, FranklinDPush the stack. The Washington register retains a copy of its previous value.
15BuchananBuchanan, JamesDPop the stack.
16LincolnLincoln, AbrahamRReset the values of all registers: Washington to 0, the rest to the uninitialized state.
17JohnsonJohnson, AndrewD
18GrantGrant, UlyssesR
19HayesHayes, RutherfordR
20GarfieldGarfield, JamesR
21ArthurArthur, ChesterR
22ClevelandCleveland, GroverD
23HarrisonHarrison, BenjaminRsame name as #9
24ClevelandCleveland, GroverDsame name (and same person) as #22
25McKinleyMcKinley, WilliamR
26RooseveltRoosevelt, TheodoreR
27TaftTaft, William HowardR
28WilsonWilson, WoodrowD
29HardingHarding, WarrenR
30CoolidgeCoolidge, CalvinR
31HooverHoover, HerbertR
32RooseveltRoosevelt, FranklinDsame name as #26
33TrumanTruman, HarryD
34EisenhowerEisenhower, DwightR
35KennedyKennedy, JohnD
36JohnsonJohnson, LyndonDsame name as #17
37NixonNixon, RichardRIllegal instruction.
38FordFord, GeraldR
39CarterCarter, JimmyD
40ReaganReagan, RonaldR
41BushBush, George H. W.R
42ClintonClinton, BillD
43BushBush, George W.Rsame name as #41
44ObamaObama, BarackD
45TrumpTrump, DonaldRReserved instruction until out of office

Examples

Hello World

Register-based
" Every nation must be founded by Washington.
Washington

" 'Jackson' increments the Washington register to 1.
Jackson

" We want to inaugurate 'Jefferson' next, but Jefferson was a
" Democratic-Republican and Jackson was a Democrat. Both parties have
" "Democrat" in the name, so it is invalid to inaugurate one after the
" other.  Harrison was a Whig, so it is valid to inaugurate Harrison
" here.  Conveniently, 'Harrison' is a no-op because the real President
" Harrison died so early on in his term.
Harrison

" 'Jefferson Washington' adds the value in the Washington register to
" the Washington register, effectively doubling it.
Jefferson Washington Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison.

" 'Monroe Adams' stores the value in the Washington register (now 8) in
" the Adams register.
Monroe Adams Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison.

" Store the value 32 in the Jefferson register, then double Washington
" one more time to 64.
Monroe Jefferson Harrison
Jefferson Washington Harrison.

" Add 8 (in Adams) to 64, then print the character 72 (ASCII 'H').
" 'Tyler' was a whig, and prints ASCII characters
Jefferson Adams Tyler

" 'VanBuren' decrements the Washington register, leading to
" 69 (ASCII 'E').
VanBuren Harrison VanBuren Harrison VanBuren Tyler

" 69 + 8 - 1 = 76 (ASCII 'L')
Jefferson Adams Harrison VanBuren Tyler

" Store 76 in Madison and print 'L' again.
Monroe Madison Tyler

" Increment 3 times to 79 and print 'O'
Jackson Harrison Jackson Harrison Jackson Tyler

" Store the value 79 in the Monroe register.
Monroe Monroe Harrison

" 'Quincy' loads the value in the given register into the Washington
" register. Jefferson contains 32 from earlier, which corresponds to
" ASCII ' ' (space).
Quincy Jefferson Tyler

" Load the value 79 back out of the Monroe register, add 8 (from the
" Adams register) = 87. Print 87 (ASCII 'W').
Quincy Monroe Harrison Jefferson Adams Tyler

" 'Madison' subtracts the value in the named register from the
" Washington register.
" Print 87 - 8 = 79 (ASCII 'O').
Madison Adams Tyler

" Increment 3 times to 82, and print ASCII 'R'.
Jackson Harrison Jackson Harrison Jackson Tyler

" Load 76 from Madison and print 'L'
Quincy Madison Tyler

" Subtract 8. 76 - 8 = 68 (ASCII 'D').
Madison Adams Tyler

" Load 32 from the Jefferson register, and add 1.
" 33 is the ASCII value of '!'.
Quincy Jefferson Harrison Jackson

" Tyler is the last president to be inaugurated. The last president in
" a Nation (program) determines its "Era", which is the last President
" whose name is allowed. It would be an error to name Polk in this
" program, because Polk served after Tyler.
Tyler!
Stack-based
" Every nation must be founded by Washington.
Washington

" Increment and double Washington up to the value of 8.
Jackson Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison

" 'Pierce' pushes the stack: Washington into Adams, Adams into
" Jefferson, and so on. This now stores 8 into Adams.
Pierce Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison

" Push again: 8 in Jefferson, 32 in Adams.
Pierce Harrison
Jefferson Washington Harrison.

" Print H: Add 8 (in Jefferson).
Jefferson Jefferson Tyler
" Print E: Decrement 3 times.
VanBuren Harrison VanBuren Harrison VanBuren Tyler
" Print L: Add 8, decrement.
Jefferson Jefferson Harrison VanBuren Tyler
" Print L, and push.
Pierce Tyler
" Print O: Increment 3 times.
Jackson Harrison Jackson Harrison Jackson Tyler
" Push O
Pierce Harrison
" Print space: 32 is now in Madison
Quincy Madison Tyler

" Print W: Pop ('Buchanan'), add 8.
Buchanan Harrison Jefferson Madison Tyler
" Print O: Subtract 8.
Madison Madison Tyler
" Print R: Increment 3 times.
Jackson Harrison Jackson Harrison Jackson Tyler
" Print L by popping it.
Buchanan Tyler
" Print D: Subtract 8.
Madison Jefferson Tyler
" Print !: ! is one past space, which is in Adams by now.
Quincy Adams Harrison Jackson Tyler!

" Pop the stack. Inconsequential at the end, but it allows Presidents up to Buchanan to be inaugurated
Buchanan

Loop

Counts down from 9 to 0.
" Every nation must be founded by Washington.
Washington

" Get to 48 (0x30 = ASCII '0') by incrementing Washington to 1, doubling
" it several times, storing 8 in Adams on the way, then adding 32+8+8.
Jackson Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison
Monroe Adams Harrison
Jefferson Washington Harrison
Jefferson Washington Harrison
Jefferson Adams Harrison
Jefferson Adams Harrison.

" Store the target value in Jefferson.
Monroe Jefferson Harrison.

" Add 10: add 8 (in Adams) and increment twice.
Jefferson Adams Harrison, Jackson Harrison, Jackson Harrison.

" Prime the loop: subtract the target value (in Jefferson).
Madison Jefferson Harrison.

" Begin the loop: Washington sets a jump target.
...Washington
	" Add the target value and decrement.
	Harrison. Jefferson Jefferson Harrison VanBuren.

	" Print the character.
	Tyler!

	" Subtract the target value.
	Madison Jefferson Harrison.

" Continue the loop until Washington equals 0.
" Since it's the last president, this Nation is set in the Polk era.
Polk...

Glossary

nation
program
president
instruction
inaugurate
execute

Copyright © Jeb Rosen 2019.