Topline is named after the top line of keys on the main part of a US PC keyboard (the row that ends with Backspace and contains the digits). It uses these 13 keys and the shift keys to perform all of its functions.
The 26 symbols and a brief summary of their job are: ~: used to reset the count to 0. !: used to print the count as a numeral. @: used to jump the instruction counter to the complementary @ and continue exexcuting there. #: used to designate a condition in a conditional loop where the count is 0. $: used in the form $x where x is the number of instructions forward the instruction counter jumps. %: used to designate a condition in a conditional loop where the count is negative. ^: used to save the count to the memory. &: used to designate a condition in a conditional loop where the count is positive. *: used to retrieve the count from the memory. ( and ): used to form loops. + and -: used to toggle the polarity. =: used to print the count as an ASCII character. `: used to seperate the designation from the body in an unconditional loop and to seperate digits that do not constitute the same number. _: used to immediately end the program. 0-9: used to alter the count via the polarity, to serve as x in a $ instruction, and to serve as the designation in an unconditional loop.
The program is set up as a list of these symbols and three invisible values that change via the instructions. The first of these is the count, which is a number that can be positive, negative, or zero. The count initializes at 0 and is changed via the instructions and often depending on the polarity. The second, the polarity, is either positive or negative. A + toggles the polarity to positive and a - toggles the polarity to negative. The polarity determines whether a numeral instruction is added to or subtracted from the count. The polarity initializes as positive. The last value, the memory, is initially empty and is filled by a value by the ^. This copies the count to the memory, but does not reset the count. The * empties the memory and sets the count to the value that was emptied from the memory. Every symbol counts as a separate instruction, but some instructions, such as consecutive numbers, work together as if they were one instruction. For example: 32 adds or subtracts 32 from the count (depending on the polarity) but 3`2 adds (or subtracts) 3, then adds (or subtracts) 2, essentially adding (or subtracting) 5 from the count. In the first example 3 and 2 are separate instructions but work as if they were one instruction to complete the task of altering the count by a multi-digit value. Another example of separate instructions working together is the $ symbol which is always followed by a single- or multi-digit number that determines the jump size. This number is implied to end at at the first non-digit instruction which represents a jump of 1. For example: 9$2@!@ is a short program that prints an endless stream of 9's. First 9 is added to the count, 9+0=9, so the count is now 9. Then there is a jump of 2 which jumps the instruction counter to the !, which prints the count, 9, as a numeral. Then the @ jumps the instruction counter to the complementary @. Then the ! prints the count, still 9 (! and = print the count, but don't reset it. Only ~ can reset the count to 0) as a numeral. Then this is endlessly repeated. A program can only have none or two @ symbols. The program is endless because there is no _ symbol to end the program. _ ends the program immediately, even if it is part of the body of a loop (see loops below).
A loop begins with a ( symbol and ends with the complementary ) symbol. If loops are nested, loops end in reverse order that they begin. Loops cannot partially overlap. There are two kinds of loops: conditional and unconditional. Conditional loops start with a ( then the next symbol is either #, %, or &. This is the condition and determines whether a loop is executed and also whether or not the loop is reexecuted. # loops execute if the count is 0. % loops execute if the count is negative. & loops execute if the count is positive. After each execution of a conditional loop, the count is rechecked against the condition to determine whether the loop reexecutes itself. If the count does not match the condition the execution continues after the corresponding ) symbol. The body is found between the condition and the ). This is the part of the loop that is executed if the condition is true. Unconditional loops begin with a single- or multi-digit number greater than 1 and then a ` symbol to seperate the number from the body of the loop. This number is called the designation because it designates the preset number of times that the body is executed. For example (2`5) adds ( or subtracts) 5 from the count two times. This is merely an example and is unnecessary because 10 completes the same thing with less instructions. After the body of an unconditional loop is executed the designated number of times, the execution continues after the corresponding ) symbol. Another rule concerning loops is that the $ and @ cannot be used in a loop's body unless the jump's target is also inside the loop's body, yet this is rare.
The following set of programs all print: Hello, world
The following program prints the lyrics to the song "99 Bottles of Beer on the wall":
99!^~$13@*(#_)(&!^~)32=~98=~111=~116==~108=~101=~*^-1+(#32=)~*^-1+(&~115=~32=~) 111=~102=~32=~98=~101==~114=~32=~111=~110=~32=~116=~104=~101=~32=~119=~97=~108==~46=~10=~*! ^~32=~98=~111=~116==~108=~101=~*^-1+(#32=)~*^-1+(&~115=~32=~) 111=~102=~32=~98=~101==~114=~46=~10=~89=~111=~117=~32=~116=~97=~107=~101=~32=~*^-1+(#105=~116=)~*^- 1+(&~111=~110=~101=~) 32=~100=~111=~119=~110=~32=~97=~110=~100=~32=~112=~97=~115==~32=~105=~116=~32=~97=~114=~111=~117=~11 0=~100=~46=~10=~*-1^+(#78=~111=)~*(&!^~)32=98=~111=~116==~108=~101=~*^-1+(#32=)~*^-1+(&~115=~32=~) *^-1+(%~115=~32=)~111=~102=~32=~98=~101==~114=~32=~111=~110=~32=~116=~104=~101=~32=~119=~97=~108==~46=~10=~@
The output is:
99 bottles of beer on the wall. 99 bottles of beer. You take one down and pass it around. 98 bottles of beer on the wall. . . . 1 bottle of beer on the wall. 1 bottle of beer. You take it down and pass it around No bottles of beer on the wall.