Bitflipper

From Esolang
Jump to navigation Jump to search

Bitflipper is a basic esoteric programming language created on March 23, 2022 by User:gapples2 where you flip bits. This only has 5 instructions which makes programming in this hard and long.

Instructions

Instruction Effect
FLIP X Flip bit X.
SKIP X Skip the next line if bit X is 1.
JUMP X Jump to line X.
OTPT X Output an ASCII character where the byte starts at X.
INPT X Set the byte starting at X to the ASCII value of an input character.
# Comments out the rest of the line.

Negative values of X enter the source code, making it possible to edit the code while it's running.

Sample programs

Cat program

INPT 0
OTPT 0
JUMP 0

Cat Program that terminates on null byte

FLIP 0 #forced skip
INPT 1
#0xxxxxxx
SKIP 1
SKIP 0
JUMP 33
#00xxxxxx
SKIP 2
SKIP 0
JUMP 33
#000xxxxx
SKIP 3
SKIP 0
JUMP 33
#0000xxxx
SKIP 4
SKIP 0
JUMP 33
#00000xxx
SKIP 5
SKIP 0
JUMP 33
#000000xx
SKIP 6
SKIP 0
JUMP 33
#0000000x
SKIP 7
SKIP 0
JUMP 33
#00000000 - input is a null byte
SKIP 8
JUMP -1 #end execution if null
OTPT 1
JUMP 1 #loop

Hello, World!

# H - 01001000
FLIP 1
FLIP 4
OTPT 0
# e - 01100101
FLIP 2
FLIP 4
FLIP 5
FLIP 7
OTPT 0
# l - 01101100
FLIP 4
FLIP 7
OTPT 0
OTPT 0
# o - 01101111
FLIP 6
FLIP 7
OTPT 0
# , - 00101100
FLIP 10
FLIP 12
FLIP 13
OTPT 8
# <space> - 00100000
FLIP 18
OTPT 16
# W - 01010111
FLIP 2
FLIP 3
FLIP 4
OTPT 0
# o - 01101111
FLIP 2
FLIP 3
FLIP 4
OTPT 0
# r - 01110010
FLIP 3
FLIP 4
FLIP 5
FLIP 7
OTPT 0
# l - 01101100
FLIP 3
FLIP 4
FLIP 5
FLIP 6
OTPT 0
# d - 01100100
FLIP 4
OTPT 0
# ! - 00100001
FLIP 23
OTPT 16

Truth Machine

FLIP 0 #guarentee a skip
INPT 1 #get input

#test for 0011000x
#0xxxxxxx
SKIP 1
SKIP 0
JUMP -1
#00xxxxxx
SKIP 2
SKIP 0
JUMP -1
#001xxxxx
SKIP 3
JUMP -1
#0011xxxx
SKIP 4
JUMP -1
#00110xxx
SKIP 5
SKIP 0
JUMP -1
#001100xx
SKIP 6
SKIP 0
JUMP -1
#0011000x
SKIP 7
SKIP 0
JUMP -1

OTPT 1 #output

#repeat if 1
SKIP 8
JUMP -1

OTPT 1
JUMP 43

Interpreters

An interpreter (here) has been written in javascript by User:dtp09, with the exceptions that you cannot modify the source code, because there was not enough info given here for me to know how to interpret it properly, and the other exception being that jumping to -1 will end execution for convenience. It is best to write the program somewhere that can number the lines, then paste to the website.

An interpreter is also being created in C++ by User:gapples2.