Linux x86_64 implementation of libglitch : https://github.com/erlehmann/libglitch.git
x86-64
nasm
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. Nils Dagsson Moskopp // erlehmann
  2. http://dieweltistgarnichtso.net
  3. December 2011
  4. The application/x-glitch Media Type for the glitch file format
  5. Status of This Memo
  6. This memo provides information for the Internet community. It does
  7. not specify an Internet standard of any kind. This memo is licensed
  8. under the Creative Commons Share-Alike license, either Version 3, or,
  9. at your option, any later version.
  10. Abstract
  11. The glitch file format is a lightweight, text-based, language-
  12. independent program interchange format. It is used to specify
  13. programs to be executed on a stack machine that generates a
  14. bitstream.
  15. Outputs of such programs are commonly interpreted as audio waveforms.
  16. Doing this, many programs have been found to produce interesting
  17. musical results, referred to as “bytebeat” [BYTEBEAT].
  18. 1. Introduction
  19. The glitch file format is a text format for the serialization of
  20. programs generating bitstreams. It is derived from the implementation
  21. of the iOS application Glitch Machine [GLITCHMACHINE].
  22. Programs noted in the glitch file format (glitches) contain
  23. instructions for a stack machine and integer constants. Its design
  24. goals were for it to be minimal, portable and textual.
  25. The glitch file format was intended to be usable in microblogging
  26. applications. Those commonly limit textual messages to 140 characters
  27. to force messages to be terse and discourage intelligent discourse
  28. [HTML].
  29. 1.1. Conventions Used in This Document
  30. The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
  31. "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
  32. document are to be interpreted as described in [RFC2119].
  33. The grammatical rules in this document are to be interpreted as
  34. described in [RFC4234].
  35. 2. Glitch File Format Grammar
  36. A glitch consists of sequences of characters. In general, a glitch is
  37. written as follows:
  38. <title>!<instructions>
  39. Title names consist of a sequence of zero or more characters, with
  40. an upper limit of 16 characters. The lower case letters "a"--"z",
  41. digits and the character underscore ("_") are allowed.
  42. Instructions consist of one or more lines, with an upper limit of 16
  43. lines.
  44. Lines start with an exclamation mark followed by a sequence of one or
  45. more token, with an upper limit of 16 tokens.
  46. A tokens can be an opcode, a number or a period (".").
  47. Opcodes tokens consist of single characters. The upper case letters
  48. "G"--"Z" and the lower case letters "a"--"z" are allowed.
  49. Numbers tokens consist of one to eight characters. The upper case
  50. letters "A"--"F" and the numbers "0"--"9" are allowed.
  51. Periods tokens are used as spacers whenever two numbers would
  52. otherwise be directly adjacent.
  53. 2.1 ABNF for the Glitch File Format
  54. alphalower = %x61-7A
  55. underscore = %x5F
  56. title = 0*16(alphalower / digit / underscore)
  57. opcode = %x47-5A / %x61-7A
  58. number = 1*8hexdig
  59. period = %x2E
  60. token = opcode / number / period
  61. newline = %0x21
  62. line = newline 1*16token
  63. instructions = 1*16line
  64. glitch = title instructions [%x0A]
  65. 2.2. Advice for Implementors
  66. For interoperability with implementations using fixed-width glyphs,
  67. programs SHOULD NOT produce glitches with lines of more than 16
  68. characters.
  69. Programs interpreting glitches SHOULD output a warning when
  70. encountering any title or line exceeding 16 characters. For
  71. robustness, programs SHOULD try to interpret such input, by
  72. truncating the title to 16 characters and splitting lines.
  73. If a program automatically truncates or splits lines, it SHOULD
  74. output a warning and SHOULD NOT let users save the changed content
  75. without further user intervention.
  76. Programs interpreting glitches MUST output a warning when
  77. encountering a sequence of more than eight characters from the set of
  78. the upper case letters "A"--"F" and the numbers "0"--"9" and SHOULD
  79. stop interpretation.
  80. Programs interpreting glitches MUST output a warning when
  81. encountering any character other than "A"--"Z", "a"--"z", "0"--"9",
  82. "_", ".", "!" or a single new line (LF) at the end of input and
  83. SHOULD stop interpretation.
  84. Warnings MUST NOT be output to the standard output.
  85. 3. Glitch Stack Machine
  86. 3.1. Stack Machine
  87. Interpreting programs written in the glitch file format is done using
  88. a virtual stack machine. The stack is a ring buffer with 256 cells
  89. that can hold an unsigned 32-bit integer and are initialized to hold
  90. a value of zero (0). In this context, setting a cell to a value means
  91. setting it to that value truncated to the last 32bits.
  92. A top-of-stack pointer (TOSP), holding an unsigned 8-bit integer,
  93. points to the current cell. Pushing a value to the stack means adding
  94. one (1) to the TOSP, then setting the current cell to that value.
  95. Popping from the stack means getting the current value, then subtracting
  96. one (1) from the TOSP.
  97. The stack machine has a global register referred to as “t”.
  98. […]
  99. 3.2. Tokenizer
  100. […]
  101. 3.3. Opcodes
  102. The following table details opcode names and their shorthands. For
  103. brevity, abbreviations are used for the top-of-stack pointer (TOSP),
  104. cell values (using stack indices within brackets “[” and “]”) and
  105. values retrieved or computed in previous numbered steps (V1, V2 …).
  106. Shorthand Name Description
  107. a T 1. Push the value of t to the stack.
  108. b PUT 1. Get [TOSP].
  109. 2. Compute V1 modulo 256.
  110. 3. Compute V2 plus 1.
  111. 4. Get [TOSP + 1]
  112. 5. Set [TOSP - V3] to V4.
  113. 6. Pop the stack.
  114. c DROP 1. Pop from the stack.
  115. d MUL 1. Pop from the stack.
  116. 2. Pop from the stack.
  117. 3. Multiply V2 and V1.
  118. 4. Push V3 to the stack.
  119. e DIV 1. Pop from the stack.
  120. 2. Pop from the stack.
  121. 3. Divide V2 by V1, in case of a division by
  122. zero yielding zero.
  123. 4. Push V3 to the stack.
  124. f ADD 1. Pop from the stack.
  125. 2. Pop from the stack.
  126. 3. Add V2 and V1.
  127. 4. Push V3 to the stack.
  128. g SUB 1. Pop from the stack.
  129. 2. Pop from the stack.
  130. 3. From V2, subtract V1.
  131. 4. Push V3 to the stack.
  132. h MOD 1. Pop from the stack.
  133. 2. Pop from the stack.
  134. 3. Compute V2 modulo V1, in case of a
  135. division by zero yielding zero.
  136. 4. Push V3 to the stack.
  137. j LSHIFT 1. Pop from the stack.
  138. 2. Pop from the stack.
  139. 3. Compute V2 bit-shifted to the left by V1,
  140. shifting in zeros, in case of an overflow
  141. yielding zero.
  142. 4. Push V3 to the stack.
  143. k RSHIFT 1. Pop from the stack.
  144. 2. Pop from the stack.
  145. 3. Compute V2 bit-shifted to the right by V1,
  146. shifting in zeros, in case of an overflow
  147. yielding zero.
  148. 4. Push V3 to the stack.
  149. l AND 1. Pop from the stack.
  150. 2. Pop from the stack.
  151. 3. Compute a bitwise AND of V2 and V1.
  152. 4. Push V3 to the stack.
  153. m OR 1. Pop from the stack.
  154. 2. Pop from the stack.
  155. 3. Compute a bitwise OR of V2 and V1.
  156. 4. Push V3 to the stack.
  157. n XOR 1. Pop from the stack.
  158. 2. Pop from the stack.
  159. 3. Compute a bitwise XOR of V2 and V1.
  160. 4. Push V3 to the stack.
  161. o NOT 1. Pop from the stack.
  162. 2. Compute the bitwise NOT of V1.
  163. 3. Push V2 to the stack.
  164. p DUP 1. Pop from the stack.
  165. 2. Push V1 to the stack.
  166. 3. Push V1 to the stack.
  167. q PICK 1. Get [TOSP].
  168. 2. Compute V1 plus 1.
  169. 3. Compute V2 modulo 256.
  170. 4. Get [TOSP - V3].
  171. 5. Pop the stack.
  172. 6. Push V4 to the stack.
  173. r SWAP 1. Pop from the stack.
  174. 2. Pop from the stack.
  175. 3. Push V1 to the stack.
  176. 4. Push V2 to the stack.
  177. s LT 1. Pop from the stack.
  178. 2. Pop from the stack.
  179. 3. If V2 is smaller than V1, push 0xFFFFFFFF
  180. to the stack.
  181. 4. If V2 is greater than V1, push 0x00000000
  182. to the stack.
  183. t GT 1. Pop from the stack.
  184. 2. Pop from the stack.
  185. 3. If V2 is greater than V1, push 0xFFFFFFFF
  186. to the stack.
  187. 4. If V2 is smaller than V1, push 0x00000000
  188. to the stack.
  189. u EQ 1. Pop from the stack.
  190. 2. Pop from the stack.
  191. 3. If V2 and V1 are equal, push 0xFFFFFFFF to
  192. the stack.
  193. 4. If V2 and V1 are not equal, push
  194. 0x00000000 to the stack.
  195. Not listed lower case and upper case letters are reserved and MUST
  196. NOT be used for opcodes. Additional opcodes can be added to the
  197. specification as soon as two independent implementations with equal
  198. output exist and at least one other implementator pledges to also
  199. implement the specified behaviour.
  200. Programs interpreting glitches MAY optimize opcode behaviour, if the
  201. output does not change.
  202. 3.4. Execution and Output
  203. Programs interpreting glitches SHOULD execute all contained opcodes
  204. 8000 times per second. Programs MUST preserve the contents of the
  205. stack between successive interpretations of the same glitch.
  206. After each time a glitch is executed, a program MUST add one to the
  207. value of t. The last 8 bits of the value on the top of the stack
  208. at this time are then taken as a sample. Samples SHOULD be written to
  209. standard output, sound devices or files.
  210. Sample output MAY happen immediately or be buffered. If buffering is
  211. used, programs that output samples on standard output SHOULD buffer
  212. at most 256 samples at a time. The resulting output frequency of
  213. 31.25hz is adequate for visualisations.
  214. 4. IANA Considerations
  215. The MIME media type for the glitch file format is
  216. application/x-glitch.
  217. Type name: application
  218. Subtype name: x-glitch
  219. Required parameters: n/a
  220. Optional parameters: n/a
  221. Encoding considerations:
  222. A glitch MUST be represented using ASCII.
  223. 5. Security Considerations
  224. The glitch file format does not in itself pose a security threat. Due
  225. to lack of branching and looping instructions a conforming
  226. implementation can not enter an infinite loop.
  227. Implementors SHOULD ensure their implementations handle variable
  228. overflows and underflows securely. Users SHOULD take note that there
  229. is no general guarantee that an implementation contains no security
  230. holes.
  231. 6. Applications that use this media type
  232. The glitch file format has been used in libglitch [LIBGLITCH].
  233. 7. References
  234. 7.1. Normative References
  235. [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
  236. Requirement Levels", BCP 14, RFC 2119, March 1997.
  237. [RFC4234] Crocker, D. and P. Overell, "Augmented BNF for Syntax
  238. Specifications: ABNF", RFC 4234, October 2005.
  239. 7.2. Informative References
  240. [BYTEBEAT] <http://canonical.org/~kragen/bytebeat/>
  241. [GLITCHMACHINE]
  242. <http://madgarden.net/apps/glitch-machine/>
  243. [HTML]
  244. <http://www.whatwg.org/specs/web-apps/current-work/
  245. multipage/common-input-element-attributes.html
  246. #attr-input-maxlength>
  247. [LIBGLITCH] <https://github.com/erlehmann/libglitch>