Original Whirl code "Hello World!" by Kang Seonghoon 7 Jan 2OO5, all rights reserved. Commented by Brennan Schweitzer 25 May 2OO5, some rights reserved. Each line represents the operation of each ring in sequence. The first line represents the effect of the instructions performed on the Operations Ring (ops). The second line does the same for the Math Ring (math). Then third line ops, fourth math, and so on... The lowercase letter "l" is used in the comments for the number one, and the uppercase letter "O" is used in the comments for the number zero. As a result, this file can be copy/pasted directly into Victor Ortiz' incredibly cool Whirl Virtual Machine. This file will run slower on the WVM than if Kang Seonghoon's program file were used, as all characters must be read by the interpreter. This is not a bad thing, as it is easier to see the operations being performed when the WVM runs slowly. Recommend beginning your copy/paste from the beginning of the actual instructions otherwise this overly wordy introduction will delay the actual onset of whirling operations. Each comment describes the effect of the command being performed, then ends with the position and current direction of the ring in the form Command:direction. Direction is indicated as cw = clockwise and ccw = counter clockwise. Abbreviations used: val = value mem = memory mem(#) = specific memory location cmp = compare stdout = standard output ascii = ummm, are you sure you're reading the right file? div = divide mult = multiply Note that this commentary format does not delve into the logic of the program. I had considered examining the programmer's logic and commenting thereon, but there are several elegant solutions in this algorithm that I leave to the reader to discover. Instruction Effect of Command, Position of Ring 1100 - place l in ops, One:cw 11100 - add mem(O) val O to math now val O, Add:cw 11100 - store ops val l in mem(O), Store:cw 00 - add mem(O) val l to math now val l, Add:cw 01111100 - Noop:ccw 00 - add mem(O) val l to math now val 2, Add:cw 00 - Noop:ccw 0100 - store math val 2 in mem(O), Store:ccw 00 - Noop:ccw 1111100 - cmp math val 2 = mem(O) val 2 true, math now val l, =:ccw 00 - Noop:ccw 11111100 - add mem(O) val 2 to math now val 3, Add:ccw 00 - Noop:ccw 00 - repeat, math val now 5, Add:ccw 00 - Noop:ccw 0100 - mult math val 5 by mem(O) val 2 math now val lO, Mult:cw 00 - Noop:ccw 01100 - store math val lO in mem(O), Store:ccw 1111100 - move to mem(l), DAdd:ccw 00 - store math val lO in mem(l), Store:ccw 1100 - store ops val l in mem(l), Store:ccw 0100 - add mem(l) val l to math now val ll, Add:cw 00 - repeat, no change, Store:ccw 0100 - Store math val ll in mem(l), Store:ccw 1111100 - Noop:ccw 0100 - add mem(l) val ll to math now val 22, Add:cw 00 - Noop:ccw 00 - add mem(l) val ll to math now val 33, Add:cw 00 - Noop:ccw 00 - add mem(l) val ll to math now val 44, Add:cw 00 - Noop:ccw 0100 - store math val 44 in mem(l), Store:ccw 1111100 - move to mem(2), DAdd:ccw 00 - store math val 44 in mem(2), Store:ccw 01111100 - Noop:cw 0100 - add mem(2) val 44 to math now val 88, Add:cw 00 - Noop:cw 00 - add mem(2) val 44 to math now val l32, Add:cw 00 - Noop:cw 00 - add mem(2) val 44 to math now val l76, Add:cw 00 - Noop:cw 00 - add mem(2) val 44 to math now val 22O, Add:cw 00 - Noop:cw 0100 - Store math val 22O in mem(2), Store:ccw 01111100 - move to mem(3), DAdd:ccw 100 - load mem(3) val O in math, Load:ccw 00 - move to mem(4), DAdd:ccw 00 - load mem(4) val O in math, Load:ccw 1100 - store ops val l in mem(4), Store:ccw 00 - load mem(4) val l in math, Load:ccw 1111100 - Noop:ccw 01100 - add mem(4) val l to math now val 2, Add:cw 00 - Noop:ccw 00 - repeat, math now val 3, Add:cw 00 - Noop:ccw 0100 - store math val 3 in mem(4), Store:ccw 1111100 - move to mem(5), DAdd:ccw 11100 - inverse, math now val -3, Neg:ccw 11100 - load mem(5) val O in ops, Load:ccw 011100 - store math val -3 in mem(5), Store:cw 00 - load mem(5) val -3 in ops, Load:ccw 0100 - load mem(5) val -3 in math, Load:ccw 011100 - move to mem(2), DAdd:cw 00 - load mem(2) val 22O in math, Load:ccw 01111100 - place l in ops, One:ccw 00 - repeat, no change, Load:ccw 01111100 - move to mem(3), DAdd:cw 100 - Noop:ccw 00 - move to mem(4), DAdd:cw 01111100 - divide math val 22O by mem(4) val 3, math now val 73.33333, Div:cw 01100 - store ops val l in mem(4), Store:ccw 11111100 - inverse math now val -73.33333, Neg:cw 00 - repeat, no change, Store:ccw 111100 - add mem(4) val l to math now val -72.33333, Add:cw 00 - repeat, no change, Store:ccw 0111100 - inverse math now val 72.33333, Neg:ccw 00 - repeat, no change, Store:ccw 011100 - store math val 72.33333 in mem(4), Store:cw 11111100 - ops val not O, stdout ascii char of mem(4) val 72 (H), AscIO:ccw 00 - repeat, no change, Store:cw 111100 - move to mem(5), DAdd:ccw 01100 - Noop:ccw 11100 - load mem(5) val -3 in ops, Load:ccw 00 - Noop:ccw 011100 - move to mem(2), DAdd:cw 0100 - load mem(2) val 22O in math, Load:cw 01111100 - place l in ops, One:ccw 00 - repeat, no change, Load:cw 01111100 - move to mem(3), DAdd:cw 100 - Store math val 22O in mem(3), Store:cw 00 - move to mem(4), DAdd:cw 01100 - Noop:ccw 00 - move to mem(5), DAdd:cw 00 - Noop:ccw 011100 - load mem(5) val -3 into ops, Load:ccw 00 - Noop:ccw 011100 - move to mem(2), DAdd:cw 01111100 - div math val 22O by mem(2) val 22O math now val l, Div:cw 01111100 - place l in ops, One:ccw 011100 - store ops val l in mem(2), Store:ccw 00 - repeat, no change, One:ccw 0100 - add mem(2) val l to math now val 2, Add:cw 00 - repeat, no change, One:ccw 0100 - store math val 2 in mem(2), Store:ccw 00 - repeat, no change, One:ccw 1100 - Noop:ccw 01111100 - move to mem(3), DAdd:cw 0100 - load mem(3) val 22O in math, Load:cw 00 - move to mem(4), DAdd:cw 0100 - Noop:ccw 00 - move to mem(5), DAdd:cw 00 - Noop:ccw 011100 - load mem(5) val -3 in ops, Load:ccw 00 - Noop:ccw 011100 - move to mem(2), DAdd:cw 100 - inverse math now val -22O, Neg:ccw 01111100 - place l in ops, One:ccw 0111100 - add mem(2) val 2 to math now val -2l8, Add:cw 00 - repeat, no change, One:ccw 0111100 - inverse math now val 2l8, Neg:ccw 00 - repeat, no change, One:ccw 11111100 - div math val 2l8 by mem(2) val 2 math now lO9, Div:cw 00 - repeat, no change, One:ccw 11111100 - inverse math now val -lO9, Neg:ccw 00 - repeat, no change, One:ccw 0111100 - add mem(2) val 2 to math now val -lO7, Add:cw 00 - repeat, no change, One:ccw 00 - add mem(2) val 2 to math now val -lO5, Add:cw 00 - repeat, no change, One:ccw 00 - add mem(2) val 2 to math now val -lO3, Add:cw 00 - repeat, no change, One:ccw 00 - add mem(2) val 2 to math now val -lOl, Add:cw 00 - repeat, no change, One:ccw 0111100 - inverse math now val lOl, Neg:ccw 00 - repeat, no change, One:ccw 011100 - store math val lOl in mem(2), Store:cw 11100 - stdout ascii char lOl (e), AscIO:ccw (stdout laugh out loud? LOL!!) 00 - repeat, no change, Store:cw 111100 - move to mem(3), DAdd:ccw 1111100 - cmp math val lOl < mem(3) val 22O true, math now val l, <:cw 01111100 - Noop:cw 01111100 - store math val l in mem(3), Store:ccw 00 - Noop:cw 0100 - add mem(3) val l to math now val 2, Add:cw 00 - Noop:cw 00 - add mem(3) val l to math now val 3, Add:cw 00 - Noop:cw 00 - add mem(3) val l to math now val 4, Add:cw 00 - Noop:cw 00 - add mem(3) val l to math now val 5, Add:cw 00 - Noop:cw 00 - add mem(3) val l to math now val 6, Add:cw 00 - Noop:cw 00 - add mem(3) val l to math now val 7, Add:cw 01111100 - move to mem(4), DAdd:ccw 011100 - Noop:ccw 00 - move to mem(5), DAdd:ccw 00 - Noop:ccw 11100 - load mem(5) val -3 in ops, Load:ccw 00 - Noop:ccw 011100 - move to mem(2), DAdd:cw 011100 - add mem(2) val lOl to math now val lO8, Add:cw 1111100 - Noop:cw 0100 - store math val lO8 in mem(2), Store:ccw 0100 - stdout ascii char lO8 (l), AscIO:ccw 00 - repeat, no change, Store:ccw 00 - repeat stdout of char lO8 (l), AscIO:ccw 00 - repeat, no change, Store:ccw 011100 - place l in ops, One:cw 00 - repeat, no change, Store:ccw 1111100 - move to mem(3), DAdd:cw 1100 - Noop:ccw 00 - move to mem(4), DAdd:cw 00 - Noop:ccw 00 - move to mem(5), DAdd:cw 100 - inverse math now val -lO8, Neg:ccw 1111100 - Noop:cw 0111100 - add mem(5) val -3 to math now val -lll, Add:cw 00 - Noop:cw 0111100 - inverse math now val lll, Neg:ccw 111100 - load mem(5) val -3 in ops, Load:cw 0100 - Noop:cw 11100 - move to mem(2), DAdd:cw 00 - Noop:cw 01111100 - place l in ops, One:ccw 00 - Noop:cw 01111100 - move to mem(3), DAdd:cw 1100 - store math val lll in mem(3), Store:cw 111100 - stdout ascii char lll (o), AscIO:cw 0100 - load mem(3) in math, no change, Load:ccw 0111100 - move to mem(4), DAdd:ccw 00 - load mem(4) in math now val 72.33333, Load:ccw 00 - move to mem(5), DAdd:ccw 00 - load mem(5) in math now val -3, Load:ccw 00 - move to mem(6), DAdd:ccw 0100 - store math val -3 in mem(6), Store:cw 01111100 - Noop:cw 100 - add mem(6) val -3 to math now val -6, Add:cw 00 - Noop:cw 0100 - store math val -6 in mem(6), Store:ccw 111100 - load mem(6) val -6 in ops, Load:cw 1100 - Noop:ccw 11100 - move to mem(O); DAdd:cw 0100 - load mem(O) val lO in math, Load:cw 01111100 - place l in ops, One:ccw 01100 - inverse math now val -lO, Neg:ccw 00 - repeat, no change, One:ccw 0100 - Noop:cw 01111100 - move to mem(l), DAdd:cw 00 - Noop:cw 111100 - stdout ascii char 44 (,), AscIO:cw 11100 - add mem(l) val 44 to math now val 34, Add:cw 11111100 - store ops val l in mem(l), Store:cw 0111100 - inverse math val now -34, Neg:ccw 00 - repeat, no change, Store:cw 0111100 - add mem(l) to math now val -33, Add:cw 01111100 - Noop:ccw 00 - add mem(l) to math now val -32, Add:cw 00 - Noop:ccw 0111100 - inverse math val now 32, Neg:ccw 00 - Noop:ccw 011100 - store math val 32 in mem(l), Store:cw 100 - stdout ascii char 32 ( ), AscIO:ccw 00 - repeat, no change, Store:cw 111100 - move to mem(2), DAdd:ccw 0100 - load mem(2) val lO8 in math, Load:ccw 01111100 - Noop:cw 1100 - inverse math now val -lO8, Neg:ccw 01111100 - move to mem(3), DAdd:ccw 0111100 - add mem(3) val lll to math now val 3, add:cw 00 - move to mem(4), DAdd:ccw 011100 - Noop:ccw 11100 - load mem(4) val 72.33333 in ops, Load:ccw 01100 - store math val 3 in mem(4) 111100 - Noop:ccw 100 - add mem(4) val 3 to math now val 6, Add:cw 00 - Noop:ccw 00 - add mem(4) val 3 to math now val 9, Add:cw 00 - Noop:ccw 00 - add mem(4) val 3 to math now val l2, Add:cw 00 - Noop:ccw 00 - add mem(4) val 3 to math now val l5, Add:cw 01111100 - store ops val 72.33333 in mem(4), Store:cw 00 - add mem(4) val 72.33333 to math now val 87.3, Add:cw 01111100 - Noop:ccw 0100 - store math val 87.3 in mem(4), Store:ccw 100 - stdout ascii char 87 (W) 00 - repeat, no change, Store:ccw 011100 - place l in ops, One:cw 00 - repeat, no change, Store:ccw 1111100 - move to mem(5), DAdd:cw 100 - load mem(5) val -3 in math, Load:ccw 00 - move to mem(6), DAdd:cw 0100 - store math val -3 in mem(6), Store:cw 011100 - load mem(6) val -3 in ops, Load ccw 00 - repeat, no change, Store:cw 011100 - move to mem(3), DAdd:cw 01100 - Noop:ccw 111100 - stdout ascii char lll (o), AscIO:cw 0100 - load mem(3) val lll in math, Load:cw 11111100 - store ops val -3 in mem(3), Store:cw 01100 - inverse math now val ?lll, Neg:ccw 00 - repeat, no change, Store:cw 0111100 - add mem(3) val -3 to math now val ?ll4, Add:cw 01111100 - Noop:ccw 0111100 - inverse math now val ll4, Neg:ccw 00 - Noop:ccw 011100 - store math val ll4 in mem(3), Store:cw 100 - stdout ascii char ll4 (r), AscIO:ccw 00 - repeat, no change, Store:cw 111100 - move to mem(O), DAdd:ccw 0100 - load mem(O) val lO in math, Load:ccw 1111100 - place l in ops, One:ccw 00 - repeat, no change, Load:ccw 01111100 - move to mem(l), DAdd:cw 00 - load mem(l) val 32 in math, Load:ccw 00 - move to mem(2), DAdd:cw 00 - load mem(2) val lO8 in math, Load:ccw 111100 - stdout ascii char lO8, (l), AscIO:cw 00 - repeat, no change, Load:ccw 0111100 - move to mem(3), DAdd:ccw 00 - load mem(3) val ll4 in math, Load:ccw 00 - move to mem(4), DAdd:ccw 00 - load mem(4) val 87.3 in math, Load:ccw 00 - move to mem(5), DAdd:ccw 00 - load mem(5) val -3 in math, Load:ccw 00 - move to mem(6), DAdd:ccw 00 - load mem(6) val -3 in math, Load:ccw 11100 - load mem(6) val -3 on ops, Load:ccw 00 - repeat, no change, Load:ccw 011100 - move to mem(3), DAdd:cw 00 - load mem(3) val ll4 in math, Load:ccw 01100 - store ops val -3 in mem(3), Store:ccw 00 - load mem(3) val -3 in math, Load:ccw 01100 - move to mem(O), DAdd:cw 00 - load mem(O) val lO in math, Load:ccw 011100 - load mem(O) val lO in ops, Load:ccw 011100 - mult math val lO by mem(O) val lO math now val lOO, Mult:cw 00 - repeat, no change, Load:ccw 01100 - store math val lOO in mem(O), Store:ccw 1111100 - stdout ascii char lOO (d), AscIO:ccw 00 - repeat, no change, Store:ccw 11111100 - store ops val lO in mem(O), Store:ccw 100 - load mem(O) val lO in math, Load:ccw 11100 - place l in ops, One:ccw 00 - repeat, no change, Load:ccw 01111100 - move to mem(l), DAdd:cw 00 - load mem(l) val 32 in math, Load:ccw 01100 - store ops val l in mem(l), Store:ccw 01100 - add mem(l) val l to math now val 33, Add:cw 00 - repeat, no change, Store:ccw 0100 - store math val 33 in mem(l), Store:ccw 11111100 - stdout ascii char 33 (!), AscIO:ccw 00 - repeat, no change, Store:ccw 011100 - place l in ops, One:cw 1100 - Noop:ccw 1111100 - move to mem(2), DAdd:cw 00 - Noop:ccw 00 - move to mem(3), DAdd:cw 00 - Noop:ccw 011100 - load mem(3) val -3 in ops, Load:ccw 00 - Noop:ccw 011100 - move to mem(O), DAdd:cw 00 - Noop:ccw 111100 - stdout ascii char lO (LF), AscIO:cw 00 - Noop:ccw 1100 - exit program, Exit:cw