SGMJQFuck

From Esolang
Jump to: navigation, search

SGMJQFuck is a brainfuck deriviative created in 2012 by User:X0wl. Although it supports all the brainfuck fuctionality and instructions, it has extensions to allow the self-modifying code.

Language overview

This language is an extended variation of the brainfuck language, extensions allow the self-modifying code. It has 3 pointers:

  1. Memory pointer - points to the current cell in the data array
  2. Code R/W pointer - points to the current cell in the code array. Code Reading/Writing uses this pointer to access the code.
  3. Execution pointer - points to the cell in the code array that is currently executed. Increments after each instruction (except [,],j)

Commands

Command Description
> Move the memory pointer to the right
< Move the memory pointer to the left
+ Increment the memory cell under the pointer
- Decrement the memory cell under the pointer
. Output the character signified by the cell at the pointer
, Input a character and store it in the cell at the pointer
[ Jump past the matching ] if the cell under the pointer is 0
] Jump back to the matching [ if the cell under the pointer is nonzero
s Set the code R/W pointer to the value of the current cell
j Jump to the address in the current cell
m Set the code cell under the code R/W pointer to the character signified in the current cell
g Set the current cell to the ASCII code of the code cell under the code R/W pointer
q Stop program execution

Example programs

Quine

<s>g.[<+>[-]j][-]+++++++++++++.q

Implementation

It was implemented by author (but in Windows PowerShell): http://pastebin.com/kcBJibHr