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.

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

(a.k.a. HAMMERANDSICKLE) is an esoteric programming language made with the goal of making programming nearly impossible.

Overview

The language is split into 2 phases of execution.

Phase 1

Phase 1 reads the source string character-by-character and executes a command. It has 8 internal registers:

  1. a (uint8, does not affect phase 2)
  2. w (uint8, does not affect phase 2)
  3. h (uint8, the rolling encryption key for output)
  4. q (uint8, the rolling encryption key for input)
  5. p (unbounded, int64 in the reference implementation, the phase 2 memory pointer)
  6. j (unbounded, int64 in the reference implementation, the phase 2 instruction count)
  7. y (unbounded, int64 in the reference implementation, the phase 2 instruction pointer)
  8. g (uint32, PRNG)

They are initialized with these values:

q = '?'
h = '#'
g = 89404137

The rest are initialized to $ 0 $.
Before each command is executed g is recalculated using this formula (where $ c $ is the current character):
$ g_{\text{new}}=g\cdot 1664525+1013904223+a+w+h+q+p+c $
The command is determined by this formula ($ o $ is the generated command, $ c $ is the current character, $ i $ is the position of the current character):
$ o=\left(\left(\left((c\oplus q)+(i{\bmod {3}})+(g\gg 24)\right){\bmod {3}}\right)+3\right){\bmod {3}} $

Command Operation
$ 0 $
  • a += 3
  • w += 7
  • q -= 43
  • p -= 13
  • g ^= 0xCAFEBABE
$ 1 $
  • a -= 2
  • w -= 5
  • q += 67
  • p += 17
  • g += a ^ w
$ 2 $ Generates a character b using this formula:

$ b=\neg \left(\left((a\lor w)\land h\right)\oplus q\oplus (g\land {\text{0xFF}})\right) $
Subtracts $ g\land 1 $ from q
Then, b is appended to the Phase 2 instruction tape and j is incremented.
If b is invalid (not *, # or ?), g is set to 0xDEADBEEF.

Phase 2

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

  • The infinite memory tape (int8 for each cell)
  • The unbounded instruction array (int8 for each instruction)
  • The memory pointer (unbounded, register p)
  • The instruction pointer (unbounded, register y)

Instructions are single ASCII characters. 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 right by $ 999983 $ positions.
Instruction pointer is even Reads a character of input, XORs it with register q, and stores it in the current memory cell, then jumps back $ 3 $ instructions.
# Current memory cell's value is $ 0 $ Jumps back 7 instructions, then modifies the instruction at that location by cycling it (*#?* → ...).
Current memory cell's value is not $ 0 $ Moves the memory pointer left by $ 999979 $ positions, then adds $ 241 $ to the current memory cell.
? Memory pointer is odd Outputs the character at the current memory cell XORred with the register h, then adds $ 239 $ to the current memory cell.
Memory pointer is even If current memory cell is $ 0 $, jump forward 12 instructions. Otherwise, set the memory pointer to g and the instruction pointer to g mod j.

Any other character is invalid and results in a crash (non-zero exit code). After each instruction is executed:

  1. h is recalculated using this formula ($ t_{p} $ is current memory cell value and $ b_{y} $ is the current instruction):
    $ h_{\text{new}}=((g\gg 16)\land {\text{0xFF}})\oplus h\oplus (t_{p}\land (b_{y}\lor q)) $
  2. $ 197 $ is added to q
  3. y is incremented

The program halts when the instruction pointer goes out of bounds.

Examples

XKCD Random Number

i[G`G0000 T2dySddP>.M!

(NOTE: Most text editors insert a newline at the end of a file, so if these examples fail, that is probably the reason)

External resources

See Also