STACKOMP

Example STACKOMP program: (logo.sk)
 v>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>v
 > rstack.....v >.p..v > p >OO d v >Smpv v
 ^ S p<<<<< A CCC , K O^ O bM p< p lR v
 ^ SSS T A A C SK O O y MM v .Qpu< v
 ^ S T rcomp..C.> ^ K O O v v S v
 ^ SSSS > T A^ < CCC K K OOO > > ^ v
 ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
 "STACKOMP" A "Stack based" 2d, reflective, esoteric programming language, and was invented by User:MartinAsdf. 
Stackcomp, short for stack compression, or maybe stack computation, is a fungoid esoteric language, meaning symbols exist on a 2d playfield, in which the insruction pointer (IP) traverses. The starts at the top left of the playfield, and moves right. Just like Befunge, Stackomp uses the <>^v characters to change the direction of the IP's movement. The IP also loops around, if it moves off of the playfield. But unlike Befunge, Stackomp does not have a stack based memory system at its disposal- instead the IP only has single cell value as memory, which it can write to, and read from.
==Syntax==
Syntax for the (at most) 1000 by 100 character grid describing a .sk program.
Each line in the file (row of characters) should be ended with a period, to denote the place of IP looping.
Example STACKOMP program: (truth_machine.sk)
 > SA RRRRRRR8888881Cv TRUTH .
 vD u< MACHINE .
 rCav < .
 D .
 >R K^ .
 > > SA RRRRRR888888Cv .
 v vDu< .
 rC .
 >pQ .
 > SA RRRRRRR8888881Cv .
 vDu< .
 rC .
 >p< .
Character : Instruction 
*< > ^ v:	Change the direction of the intruction pointer movement
*0 1 ... 9:	Numerical cell of the specified value
*X C M:	Numerical cell of value 10, 100 and 1000 respectivley
*S:	Read the following cell into memory
*u r d l:	Pull from the stack in the specified direction (up right down left)
*U R D L:	Push into the stack in specified direction (with conditional subtractions, see Overview:Data manipulation)
*K:	Read the askii value of the user inputed character as a numerical value (ascii code)
*p:	Print the current value in memory as a character
*P:	Print the current value in memory as a decimal number
*Q: Halt and terminate program.
==Overview==
===The Stackomp playfield===
The Stackomp playfield contains a 2d array of cells (at most 1000 wide and 100 tall). Each cell either stores a character, a number, or white space. The playfield is loaded from a .sk text file. Space and newline characters are considered whitespace. The characters 0 through 9, X, C and M are considered numbers. Everything else is considered a character. Of these characters, several of them are instruction characters (like <>^v), but they behave and can be manipulate in the same way as other characters.
===Data manipulation===
The S, u, r, d, l characters are used for reading data off of the playfield. S: When the IP runs into the S character, it'll store the next (non whitespace) cell into it's memory. This includes instruction characters also, effectivley ignoring them. u,r,d,l: Passing by these lower case directional instuction "pulls" from the stack pointing in that direction, storing the nearest cell into memory, and shifting all cells following it toards the character (stopping at whitespace). Pulling cells will also loop around the playfield, so insure there is always whitespace between things you want to keep seperate. For example (& represents the IP): If the IP is moving right in this example,
 &> d 
 H
 I
 >
the result would be
 > d &
 I
 >
 
with the IP storing an H character. The main gimmic of Stackomp is, the items in the playfield act as stacks that the IP can manipulate.
The U,R,D,L characters (Upper case directional instructions) push from the stack pointing in each direction. If the memory and stack contain only characters, it acts exactly like you would expect (the opposite of pushing), other than the fact that the IP retains its memory. So if the IP was storing K in this example:
 &> D
 H
 I
 >
the result would be
 > D &
 K
 H
 I
 >
But the interaction is different for number cells. Numbers and characters will never interact, but if a smaller number is pushed into the cell of a larger number, the larger number will subtract the smaller (and the push will stop) So if the IP was storing numerical 2 in this case:
 &> D
 5
 9
 >
the result would be
 > D & 
 3
 9 
 >
, but if the IP was storing numerical 8, the result would be:
 > D & 
 8
 4
 >
(the 5 gets pushed into the 9) This operation is the only means of doing calculations, or logical branching. An example of logical branching would be if pushing a larger number into a smaller one moves a 'v' out of the way of the IP's path, causing a branch, compared to if the original number was smaller. Doing conditional branching requires the code to change itself, and most of the time, destroy itself.
===Input and output===
The K character is used for user input, and the p and P characters are used for displaying to the screen. See Syntax section.
==Usage/Interpreter==
 Interpreter and example .sk files available at [] See Usage sections for running interpreters.
== Examples == 
=== Truth Machine ===
Example STACKOMP program: (truth_machine.sk)
 > SA RRRRRRR8888881Cv TRUTH .
 vD u< MACHINE .
 rCav < .
 D .
 >R K^ .
 > > SA RRRRRR888888Cv .
 v vDu< .
 rC .
 >pQ .
 > SA RRRRRRR8888881Cv .
 vDu< .
 rC .
 >p< .
Truth-machine is a simple Popular_problem that displays branching and looping: 
* Ask for input.
* If the input is 0:
** Output 0.
** Terminate program.
* Whereas if the input is 1:
** Repeat infinitely:
*** Output 1.
The ascii code for 0 is 48. The overview of this truth machine implementation is as so:
* Store the number 48 in IP
* Place onto field
* Pick up number from user input (K)
* Place onto field such that it combines with the 48 if the input is 48, causing a conditional shift in a > which results in branching
* If input is 48: 
** Store the number 48 in IP
** Print it as char
** Terminate
* If input is 49 (or other):
** Loop : 
*** Store the number 49 in IP
*** Print it
===99 Bottles Of Beer===
99 bottles of beer is a Popular_problem that "sings" the titular song. This implementation has no ending, or plurals.
 > SARRRRXXX2Cl RCv .
 v u< > DS1 v > v .
 vr L < > v .
 >S1 Dv > v > v ^ ^< .
 Cl > v > ^ > v > vA S .
 >D^ >D D D D D D D^>D^>D D D D D D D D D D^>D^>D D D D D D v R 1 .
 > > S P S pv>S pv>S pv>S pv>S pv>S pv>S pS PS pv>S pv>S pv>S pv>S pv>S pv>S pv>S pv>S pv>S pS PS pv>S pv>S pv>S pv>S pv>S pv> S1 U^ .
 ^ U U U < .
 ^ < .
 ^ < .
 ^ < .
 >SwpSapSlpSlpSXp^ .
 ^ < .
 >StpShpSep^ .
 ^ < .
 >SopSnp^ .
 ^prSpeS< .
 >SbpSep ^ .
 ^ < .
 >SopSfp^ .
 ^ psSpeSplS< .
 >SbpSopStpStp^ .
 ^ < .
 >SapSrpSopSupSnpSdpS,p^ Q < .
 ^ < .
 >SipStp^ .
 ^ < .
 >SppSapSspSsp^ .
 ^ < .
 >SdpSopSwpSnpS,p^ .
 ^ < .
 >SopSnpSep^ .
 ^ < .
 >StpSapSkpSep^ .
 ^ < .
 >SbpSepSepSrpSXp^ .
 ^ < .
 >SopSfp^ .
 ^ < .
 >SbpSopStpStpSlpSepSsp^ .
 ^ < .
 >SwpSapSlpSlpS,p^ .
 ^ < .
 >StpShpSep^ .
 ^ < .
 >SopSnp^ .
 ^prSpeS< .
 >SbpSep ^ .
 ^ < .
 >SopSfp^ .
 ^ psSpeSplS< .
 >SbpSopStpStp^ .
 .
This program won't be explained.
Category:Languages