We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

SGA

From Esolang
Jump to navigation Jump to search

StackGolfAssembly, also known as SGA for short, is a stack-based language created by User:OfficialWatchOS7Alt.

Nomenclature

The letters in the acronym reflect different aspects of SGA:

  • S (Stack): The language is stack-based.
  • G (Golf): The language uses intentionally short commands.
  • A (Assembly): The language uses all fundamental stack manipulation commands.

Commands

In SGA, only values from a range of -16,777,217 and 16,777,216 can be pushed, in a list of values from this range whether they are of the two statuses of an SGA value: undropped (the default) or dropped (the value cannot be pushed unless it is restored by the @[x] command). Please note that the descriptions were (partially) generated by a large-language model, so please improve the descriptions if you can.

  • +[x]: Push value x onto the stack
  • -[x]: Drop value x from the stack and mark it as dropped
  • @[x]: Restore a dropped value and push it back onto the stack
  • ^[x]: Pop value x and print it as a UTF-8 character, when the value is set to Ans it returns the latest value of the special variable Ans
    • *x: Added to the ^[x] command, this suffix repeats the printing from the command a specific amount of times; if set to I, it repeats infinitely.
  • +{x}{y}: Pop two values and push their sum
  • -{x}{y}: Pop two values and push their difference
  • *{x}{y}: Pop two values and push their product
  • /{x}{y}: Pop two values and push their quotient
  • %{x}{y}: Pop two values and push their remainder
  • ,: Request user input and store it in the special variable Ans
  • [operation]&x=y?: Check whether an arithmetic operation produces a specified result
  • Ans=str?: Check whether Ans matches a specified string
  • x=dropped?: Check whether a value is currently dropped
  • :[x]: Duplicate a value on the stack
  • $[x][y]: Swap two values on the stack
  • C[x]: Move a specified value to the top of the stack (over operation)
  • R[x][y][z]: Rotate three values clockwise
  • r[x][y][z]: Rotate three values counterclockwise

Programs

Please note that there is no 99 bottles of beer program because this language does not have for loops.

Hello World program

+[72]^[72]
+[101]^[101]
+[108]^[108]
+[108]^[108]
+[111]^[111]
+[44]^[44]
+[32]^[32]
+[87]^[87]
+[111]^[111]
+[114]^[114]
+[108]^[108]
+[100]^[100]
+[33]^[33]

Cat program

,
^[Ans]

Truth-machine

,
Ans=1?
+[49]^[49]*I
Ans=0?
+[48]^[48]