From Esolang
Jump to navigation Jump to search
Paradigm(s) imperative
turing tarpit
Designed by User:Dragoneater67
Appeared in 2026
Memory system Cell-based
Dimensions one-dimensional
Computational class Unknown
Major implementations C++
Influenced by #b
!I!M!P!O!S!S!I!B!L!E!
Brainfuck
Influenced
File extension(s) .hammerandsickle

is an esoteric programming language made by User:Dragoneater67. The goal of the language is to make doing trivial operations nearly impossible.

Overview

The language is separated into 2 phases of execution. The overview is very brief as it is hard to explain the workings of ☭. Refer to the reference implementation to get a better understanding of the language.

Phase 1

Phase 1 reads the source string character-by-character and executes a command. The state is initialized with these values:

a = 0
w = 0
q = '?'
p = 0
h = '#'
g = 89404137

Before each command is executed g is regenerated using this formula:

The command is determined by this formula ( is the generated command, is the current character, is the position of the current character):

Selector Type Operation
0 State mutation Mutates internal accumulators and shifts keys:
  • a += 3
  • w += 7
  • q -= 43 (Input key rotation)
  • p -= 13 (Memory pointer shift)
  • g ^= 0xCAFEBABE (PRNG scramble)
1 State mutation Mutates internal accumulators and shifts keys:
  • a -= 2
  • w -= 5
  • q += 67 (Input key rotation)
  • p += 17 (Memory pointer shift)
  • g += a ^ w (PRNG mix)
2 Instruction generation Synthesizes a candidate byte b using the formula:


Then, it is appended to the Phase 2 instruction tape.
If b is invalid (not *, # or ?), the PRNG is penalized (g = 0xDEADBEEF).

Phase 2

Phase 2 is a virtual machine that executes the bytecode generated in phase 1. The virtual machine has:

  • The unbounded memory tape (in the reference implementation the length is )
  • The unbounded instruction tape (in the reference implementation the length is )
  • The memory pointer
  • The instruction pointer

The memory pointer is initially pseudorandom (derived from the source string), while the instruction pointer is always initialized to . Instructions are single ASCII characters, any other ASCII character is an invalid character and will result in an error. Here is a quick overview of available commands:

Instruction Condition Operation
* Instruction pointer is Odd Adds 251 to the current memory cell, then moves the memory pointer forward by 999983 positions.
Instruction pointer is Even Reads a byte from input, XORs it with register q, and stores it in the current memory cell, then jumps back 3 steps.
# Current memory cell is 0 Jumps back 7 steps, then modifies the instruction at that location by cycling it (*#?* → ...).
Current memory cell is not 0 Moves the memory pointer backward by 999979 positions, then adds 241 to the current memory cell.
? Memory pointer is Odd Outputs the character at the current memory cell XORed with register h, then adds 239 to the current memory cell.
Memory pointer is Even If current memory cell is 0, skip forward 12 instructions. Otherwise, set both memory pointer and the instruction pointer to pseudo-random values derived from g.

The virtual machine has 8 internal registers:

  1. a (uint8, phase 1 only, does not affect the state of the virtual machine)
  2. w (uint8, phase 1 only, does not affect the state of the virtual machine)
  3. h (uint8, the rolling encryption key for output)
  4. q (uint8, the rolling encryption key for input)
  5. p (unbounded, the memory pointer)
  6. j (unbounded, The instruction count)
  7. y (unbounded, the instruction pointer)
  8. g (uint32, PRNG)

After each instruction is executed, y is incremented by 1, q is incremented by 197, and the new h is calculated using this formula ( is current memory cell value and is the current instruction):

Examples

XKCD RANDOM NUMBER

iKrupBIJ2Ge7eJB6Wjav-stfem+d8zvCao9=a60U29ceE0KStlgieCyrUoCq0n = xkcd(36);

External resources

See Also