Hardlang
Jump to navigation
Jump to search
Hardlang is based on a single accumulator A, which is exactly one word in length. Constants are very hard to represent in it. At the start of a program, A = 0.
Instructions
These are the language's instructions:
- !: Inversion: This instruction inverts all bits in the accumulator.
- <: Shift Right: This instruction shifts every bit in A one place to the right. The leftmost bit becomes a zero and the rightmost bit is discarded.
After every operation, hardlang will output the content of the accumulator.
Example programs
Under a nibble:
0: 1:!<! 2:!<!< 3:!<<! 4:!<!<< 5:!<!<!<! 6:!<<!< 7:!<<<! 8:!<<< 9:!<<!<! 10:!<!<!< 11:!<!<<! 12:!<< 13:!<!<! 14:!< 15:!
Interpreter
Written in JavaScript (66 bytes). Pass it the program as an argument. Don't pass a.
var hardlang=(c,a=0)=>c.map(h=>{h=="!"&&(a=~a);h=="<"&&(a>>=1);});