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 .
Before each command is executed g is recalculated using this formula (where is the current character):

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

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


Subtracts 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 to the current memory cell, then moves the memory pointer right by 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 instructions.
# Current memory cell is zero Jumps back 7 instructions, then modifies the instruction at that location by cycling it (*#?* → ...).
Current memory cell is not zero Moves the memory pointer left by positions, then adds to the current memory cell.
? Memory pointer is odd Outputs the character at the current memory cell XORred with the register h, then adds to the current memory cell.
Memory pointer is even If current memory cell is , 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 ( is current memory cell value and is the current instruction):
  2. 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